3 XML::LibXML::Attr - XML::LibXML Attribute Class
10 # Only methods specific to Attribute nodes are listed here,
11 # see XML::LibXML::Node manpage for other methods
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);
20 $string = $attr->serializeContent;
24 This is the interface to handle Attributes like ordinary nodes. The naming of
25 the class relies on the W3C DOM documentation.
30 The class inherits from L<<<<<< XML::LibXML::Node >>>>>>. The documentation for Inherited methods is not listed here.
32 Many functions listed here are extensively documented in the DOM Level 3 specification (L<<<<<< http://www.w3.org/TR/DOM-Level-3-Core/ >>>>>>). Please refer to the specification for extensive documentation.
38 $attr = XML::LibXML::Attr->new($name [,$value]);
40 Class constructor. If you need to work with ISO encoded strings, you should I<<<<<< always >>>>>> use the C<<<<<< createAttrbute >>>>>> of L<<<<<< XML::LibXML::Document >>>>>>.
45 $string = $attr->getValue();
47 Returns the value stored for the attribute. If undef is returned, the attribute
48 has no value, which is different of being C<<<<<< not specified >>>>>>.
53 $string = $attr->value;
55 Alias for I<<<<<< getValue() >>>>>>
60 $attr->setValue( $string );
62 This is needed to set a new attribute value. If ISO encoded strings are passed
63 as parameter, the node has to be bound to a document, otherwise the encoding
64 might be done incorrectly.
69 $node = $attr->getOwnerElement();
71 returns the node the attribute belongs to. If the attribute is not bound to a
72 node, undef will be returned. Overwriting the underlying implementation, the I<<<<<< parentNode >>>>>> function will return undef, instead of the owner element.
77 $attr->setNamespace($nsURI, $prefix);
79 This function tries to bound the attribute to a given namespace. If C<<<<<< $nsURI >>>>>> is undefined or empty, the function discards any previous association of the
80 attribute with a namespace. If the namespace was not previously declared in the
81 context of the attribute, this function will fail. In this case you may wish to
82 call setNamespace() on the ownerElement. If the namespace URI is non-empty and
83 declared in the context of the attribute, but only with a different (non-empty)
84 prefix, then the attribute is still bound to the namespace but gets a different
85 prefix than C<<<<<< $prefix >>>>>>. The function also fails if the prefix is empty but the namespace URI is not
86 (because unprefixed attributes should by definition belong to no namespace).
87 This function returns 1 on success, 0 otherwise.
94 Determine whether an attribute is of type ID. For documents with a DTD, this
95 information is only available if DTD loading/validation has been requested. For
96 HTML documents parsed with the HTML parser ID detection is done automatically.
97 In XML documents, all "xml:id" attributes are considered to be of type ID.
100 =item serializeContent($docencoding)
102 $string = $attr->serializeContent;
104 This function is not part of DOM API. It returns attribute content in the form
105 in which it serializes into XML, that is with all meta-characters properly
106 quoted and with raw entity references (except for entities expanded during
107 parse time). Setting the optional $docencoding flag to 1 enforces document
108 encoding for the output string (which is then passed to Perl as a byte string).
109 Otherwise the string is passed to Perl as (UTF-8 encoded) characters.
128 2001-2007, AxKit.com Ltd.
130 2002-2006, Christian Glahn.
132 2006-2009, Petr Pajas.