1XML::LibXML::Attr(3) User Contributed Perl Documentation XML::LibXML::Attr(3)
2
3
4
6 XML::LibXML::Attr - XML::LibXML Attribute Class
7
9 use XML::LibXML;
10 # Only methods specific to Attribute nodes are listed here,
11 # see 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
23 This is the interface to handle Attributes like ordinary nodes. The
24 naming of the class relies on the W3C DOM documentation.
25
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/
32 <http://www.w3.org/TR/DOM-Level-3-Core/>). Please refer to the
33 specification for extensive documentation.
34
35 new
36 $attr = XML::LibXML::Attr->new($name [,$value]);
37
38 Class constructor. If you need to work with ISO encoded strings,
39 you should always use the "createAttrbute" of
40 XML::LibXML::Document.
41
42 getValue
43 $string = $attr->getValue();
44
45 Returns the value stored for the attribute. If undef is returned,
46 the attribute has no value, which is different of being "not
47 specified".
48
49 value
50 $string = $attr->value;
51
52 Alias for getValue()
53
54 setValue
55 $attr->setValue( $string );
56
57 This is needed to set a new attribute value. If ISO encoded strings
58 are passed as parameter, the node has to be bound to a document,
59 otherwise the encoding might be done incorrectly.
60
61 getOwnerElement
62 $node = $attr->getOwnerElement();
63
64 returns the node the attribute belongs to. If the attribute is not
65 bound to a node, undef will be returned. Overwriting the underlying
66 implementation, the parentNode function will return undef, instead
67 of the owner element.
68
69 setNamespace
70 $attr->setNamespace($nsURI, $prefix);
71
72 This function tries to bound the attribute to a given namespace. If
73 $nsURI is undefined or empty, the function discards any previous
74 association of the attribute with a namespace. If the namespace was
75 not previously declared in the context of the attribute, this
76 function will fail. In this case you may wish to call
77 setNamespace() on the ownerElement. If the namespace URI is non-
78 empty and declared in the context of the attribute, but only with a
79 different (non-empty) prefix, then the attribute is still bound to
80 the namespace but gets a different prefix than $prefix. The
81 function also fails if the prefix is empty but the namespace URI is
82 not (because unprefixed attributes should by definition belong to
83 no namespace). This function returns 1 on success, 0 otherwise.
84
85 isId
86 $bool = $attr->isId;
87
88 Determine whether an attribute is of type ID. For documents with a
89 DTD, this information is only available if DTD loading/validation
90 has been requested. For HTML documents parsed with the HTML parser
91 ID detection is done automatically. In XML documents, all "xml:id"
92 attributes are considered to be of type ID.
93
94 serializeContent($docencoding)
95 $string = $attr->serializeContent;
96
97 This function is not part of DOM API. It returns attribute content
98 in the form in which it serializes into XML, that is with all meta-
99 characters properly quoted and with raw entity references (except
100 for entities expanded during parse time). Setting the optional
101 $docencoding flag to 1 enforces document encoding for the output
102 string (which is then passed to Perl as a byte string). Otherwise
103 the string is passed to Perl as (UTF-8 encoded) characters.
104
106 Matt Sergeant, Christian Glahn, Petr Pajas
107
109 1.70
110
112 2001-2007, AxKit.com Ltd.
113
114 2002-2006, Christian Glahn.
115
116 2006-2009, Petr Pajas.
117
118
119
120perl v5.12.0 2009-10-07 XML::LibXML::Attr(3)