1XML::DOM::Attr(3) User Contributed Perl Documentation XML::DOM::Attr(3)
2
3
4
6 XML::DOM::Attr - An XML attribute in XML::DOM
7
9 XML::DOM::Attr extends XML::DOM::Node.
10
11 The Attr nodes built by the XML::DOM::Parser always have one child node
12 which is a Text node containing the expanded string value (i.e.
13 EntityReferences are always expanded.) EntityReferences may be added
14 when modifying or creating a new Document.
15
16 The Attr interface represents an attribute in an Element object.
17 Typically the allowable values for the attribute are defined in a
18 document type definition.
19
20 Attr objects inherit the Node interface, but since they are not
21 actually child nodes of the element they describe, the DOM does not
22 consider them part of the document tree. Thus, the Node attributes
23 parentNode, previousSibling, and nextSibling have a undef value for
24 Attr objects. The DOM takes the view that attributes are properties of
25 elements rather than having a separate identity from the elements they
26 are associated with; this should make it more efficient to implement
27 such features as default attributes associated with all elements of a
28 given type. Furthermore, Attr nodes may not be immediate children of a
29 DocumentFragment. However, they can be associated with Element nodes
30 contained within a DocumentFragment. In short, users and implementors
31 of the DOM need to be aware that Attr nodes have some things in common
32 with other objects inheriting the Node interface, but they also are
33 quite distinct.
34
35 The attribute's effective value is determined as follows: if this
36 attribute has been explicitly assigned any value, that value is the
37 attribute's effective value; otherwise, if there is a declaration for
38 this attribute, and that declaration includes a default value, then
39 that default value is the attribute's effective value; otherwise, the
40 attribute does not exist on this element in the structure model until
41 it has been explicitly added. Note that the nodeValue attribute on the
42 Attr instance can also be used to retrieve the string version of the
43 attribute's value(s).
44
45 In XML, where the value of an attribute can contain entity references,
46 the child nodes of the Attr node provide a representation in which
47 entity references are not expanded. These child nodes may be either
48 Text or EntityReference nodes. Because the attribute type may be
49 unknown, there are no tokenized attribute values.
50
51 METHODS
52 getValue
53 On retrieval, the value of the attribute is returned as a string.
54 Character and general entity references are replaced with their
55 values.
56
57 setValue (str)
58 DOM Spec: On setting, this creates a Text node with the unparsed
59 contents of the string.
60
61 getName
62 Returns the name of this attribute.
63
64
65
66perl v5.16.3 2000-01-31 XML::DOM::Attr(3)