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 $attr = XML::LibXML::Attr->new($name [,$value]);
10 $string = $attr->getValue();
11 $string = $attr->value;
12 $attr->setValue( $string );
13 $node = $attr->getOwnerElement();
14 $attr->setNamespace($nsURI, $prefix);
15 $bool = $attr->isId;
16 $string = $attr->serializeContent;
17
19 This is the interface to handle Attributes like ordinary nodes. The
20 naming of the class relies on the W3C DOM documentation.
21
22 new
23 $attr = XML::LibXML::Attr->new($name [,$value]);
24
25 Class constructor. If you need to work with iso encoded strings,
26 you should always use the createAttrbute of XML::LibXML::Document.
27
28 getValue
29 $string = $attr->getValue();
30
31 Returns the value stored for the attribute. If undef is returned,
32 the attribute has no value, which is different of being not speci‐
33 fied.
34
35 value
36 $string = $attr->value;
37
38 Alias for getValue()
39
40 setValue
41 $attr->setValue( $string );
42
43 This is needed to set a new attribute value. If iso encoded strings
44 are passed as parameter, the node has to be bound to a document,
45 otherwise the encoding might be done incorrectly.
46
47 getOwnerElement
48 $node = $attr->getOwnerElement();
49
50 returns the node the attribute belongs to. If the attribute is not
51 bound to a node, undef will be returned. Overwriting the underlying
52 implementation, the parentNode function will return undef, instead
53 of the owner element.
54
55 setNamespace
56 $attr->setNamespace($nsURI, $prefix);
57
58 This function tries to bound the attribute to a given namespace. If
59 $nsURI is undefined or empty, the function discards any previous
60 association of the attribute with a namespace. If the namespace was
61 not previously declared in the context of the attribute, this func‐
62 tion will fail. In this case you may wish to call setNamespace() on
63 the ownerElement. If the namespace URI is non-empty and declared in
64 the context of the attribute, but only with a different (non-empty)
65 prefix, then the attribute is still bound to the namespace but gets
66 a different prefix than $prefix. The function also fails if the
67 prefix is empty but the namespace URI is not (because unprefixed
68 attributes should by definition belong to no namespace). This func‐
69 tion returns 1 on success, 0 otherwise.
70
71 isId
72 $bool = $attr->isId;
73
74 Determine whether an attribute is of type ID. For documents with a
75 DTD, this information is only available if DTD loading/validation
76 has been requested. For HTML documents parsed with the HTML parser
77 ID detection is done automatically. In XML documents, all "xml:id"
78 attributes are considered to be of type ID.
79
80 serializeContent($docencoding)
81 $string = $attr->serializeContent;
82
83 This functin is not part of DOM API. It returns attribute content
84 in the form in which it serializes into XML, that is with all meta-
85 characters properly quoted and with raw entity references (except
86 for entities expanded during parse time). Setting the optional
87 $docencoding flag to 1 enforces document encoding for the output
88 string (wich is then passed to Perl as a byte string). Otherwise
89 the string is passed to Perl as (UTF-8 encododed) characters.
90
92 Matt Sergeant, Christian Glahn, Petr Pajas,
93
95 1.62
96
98 2001-2006, AxKit.com Ltd; 2002-2006 Christian Glahn; 2006 Petr Pajas,
99 All rights reserved.
100
101
102
103perl v5.8.8 2006-11-17 XML::LibXML::Attr(3)