1XML::LibXML::Attr(3)  User Contributed Perl Documentation XML::LibXML::Attr(3)
2
3
4

NAME

6       XML::LibXML::Attr - XML::LibXML Attribute Class
7

SYNOPSIS

9         use XML::LibXML;
10         # Only methods specific to Attribute nodes are listed here,
11         # see the XML::LibXML::Node manpage for other methods
12
13         $attr = XML::LibXML::Attr->new($name [,$value]);
14         $string = $attr->getValue();
15         $string = $attr->value;
16         $attr->setValue( $string );
17         $node = $attr->getOwnerElement();
18         $attr->setNamespace($nsURI, $prefix);
19         $bool = $attr->isId;
20         $string = $attr->serializeContent;
21

DESCRIPTION

23       This is the interface to handle Attributes like ordinary nodes. The
24       naming of the class relies on the W3C DOM documentation.
25

METHODS

27       The class inherits from XML::LibXML::Node. The documentation for
28       Inherited methods is not listed here.
29
30       Many functions listed here are extensively documented in the DOM Level
31       3 specification (<http://www.w3.org/TR/DOM-Level-3-Core/>). Please
32       refer to the specification for extensive documentation.
33
34       new
35             $attr = XML::LibXML::Attr->new($name [,$value]);
36
37           Class constructor. If you need to work with ISO encoded strings,
38           you should always use the "createAttribute" of
39           XML::LibXML::Document.
40
41       getValue
42             $string = $attr->getValue();
43
44           Returns the value stored for the attribute. If undef is returned,
45           the attribute has no value, which is different of being "not
46           specified".
47
48       value
49             $string = $attr->value;
50
51           Alias for getValue()
52
53       setValue
54             $attr->setValue( $string );
55
56           This is needed to set a new attribute value. If ISO encoded strings
57           are passed as parameter, the node has to be bound to a document,
58           otherwise the encoding might be done incorrectly.
59
60       getOwnerElement
61             $node = $attr->getOwnerElement();
62
63           returns the node the attribute belongs to. If the attribute is not
64           bound to a node, undef will be returned. Overwriting the underlying
65           implementation, the parentNode function will return undef, instead
66           of the owner element.
67
68       setNamespace
69             $attr->setNamespace($nsURI, $prefix);
70
71           This function tries to bound the attribute to a given namespace. If
72           $nsURI is undefined or empty, the function discards any previous
73           association of the attribute with a namespace. If the namespace was
74           not previously declared in the context of the attribute, this
75           function will fail. In this case you may wish to call
76           setNamespace() on the ownerElement. If the namespace URI is non-
77           empty and declared in the context of the attribute, but only with a
78           different (non-empty) prefix, then the attribute is still bound to
79           the namespace but gets a different prefix than $prefix. The
80           function also fails if the prefix is empty but the namespace URI is
81           not (because unprefixed attributes should by definition belong to
82           no namespace).  This function returns 1 on success, 0 otherwise.
83
84       isId
85             $bool = $attr->isId;
86
87           Determine whether an attribute is of type ID. For documents with a
88           DTD, this information is only available if DTD loading/validation
89           has been requested. For HTML documents parsed with the HTML parser
90           ID detection is done automatically.  In XML documents, all "xml:id"
91           attributes are considered to be of type ID.
92
93       serializeContent($docencoding)
94             $string = $attr->serializeContent;
95
96           This function is not part of DOM API. It returns attribute content
97           in the form in which it serializes into XML, that is with all meta-
98           characters properly quoted and with raw entity references (except
99           for entities expanded during parse time). Setting the optional
100           $docencoding flag to 1 enforces document encoding for the output
101           string (which is then passed to Perl as a byte string).  Otherwise
102           the string is passed to Perl as (UTF-8 encoded) characters.
103

AUTHORS

105       Matt Sergeant, Christian Glahn, Petr Pajas
106

VERSION

108       2.0208
109
111       2001-2007, AxKit.com Ltd.
112
113       2002-2006, Christian Glahn.
114
115       2006-2009, Petr Pajas.
116

LICENSE

118       This program is free software; you can redistribute it and/or modify it
119       under the same terms as Perl itself.
120
121
122
123perl v5.36.0                      2022-09-30              XML::LibXML::Attr(3)
Impressum