1XML::DOM::NamedNodeMap(U3s)er Contributed Perl DocumentatXiMoLn::DOM::NamedNodeMap(3)
2
3
4
6 XML::DOM::NamedNodeMap - A hash table interface for XML::DOM
7
9 Objects implementing the NamedNodeMap interface are used to represent
10 collections of nodes that can be accessed by name. Note that
11 NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not
12 maintained in any particular order. Objects contained in an object
13 implementing NamedNodeMap may also be accessed by an ordinal index, but
14 this is simply to allow convenient enumeration of the contents of a
15 NamedNodeMap, and does not imply that the DOM specifies an order to
16 these Nodes.
17
18 Note that in this implementation, the objects added to a NamedNodeMap
19 are kept in order.
20
21 METHODS
22 getNamedItem (name)
23 Retrieves a node specified by name.
24
25 Return Value: A Node (of any type) with the specified name, or
26 undef if the specified name did not identify any node in the map.
27
28 setNamedItem (arg)
29 Adds a node using its nodeName attribute.
30
31 As the nodeName attribute is used to derive the name which the node
32 must be stored under, multiple nodes of certain types (those that
33 have a "special" string value) cannot be stored as the names would
34 clash. This is seen as preferable to allowing nodes to be aliased.
35
36 Parameters:
37 arg A node to store in a named node map.
38
39 The node will later be accessible using the value of the nodeName
40 attribute of the node. If a node with that name is already present
41 in the map, it is replaced by the new one.
42
43 Return Value: If the new Node replaces an existing node with the
44 same name the previously existing Node is returned, otherwise undef
45 is returned.
46
47 DOMExceptions:
48
49 · WRONG_DOCUMENT_ERR
50
51 Raised if arg was created from a different document than the
52 one that created the NamedNodeMap.
53
54 · NO_MODIFICATION_ALLOWED_ERR
55
56 Raised if this NamedNodeMap is readonly.
57
58 · INUSE_ATTRIBUTE_ERR
59
60 Raised if arg is an Attr that is already an attribute of
61 another Element object. The DOM user must explicitly clone
62 Attr nodes to re-use them in other elements.
63
64 removeNamedItem (name)
65 Removes a node specified by name. If the removed node is an Attr
66 with a default value it is immediately replaced.
67
68 Return Value: The node removed from the map or undef if no node
69 with such a name exists.
70
71 DOMException:
72
73 · NOT_FOUND_ERR
74
75 Raised if there is no node named name in the map.
76
77 item (index)
78 Returns the indexth item in the map. If index is greater than or
79 equal to the number of nodes in the map, this returns undef.
80
81 Return Value: The node at the indexth position in the NamedNodeMap,
82 or undef if that is not a valid index.
83
84 getLength
85 Returns the number of nodes in the map. The range of valid child
86 node indices is 0 to length-1 inclusive.
87
88 Additional methods not in the DOM Spec
89 getValues
90 Returns a NodeList with the nodes contained in the NamedNodeMap.
91 The NodeList is "live", in that it reflects changes made to the
92 NamedNodeMap.
93
94 When this method is called in a list context, it returns a regular
95 perl list containing the values. Note that this list is not "live".
96 E.g.
97
98 @list = $map->getValues; # returns a perl list
99 $nodelist = $map->getValues; # returns a NodeList (object ref.)
100 for my $val ($map->getValues) # iterate over the values
101
102 getChildIndex (node)
103 Returns the index of the node in the NodeList as returned by
104 getValues, or -1 if the node is not in the NamedNodeMap.
105
106 dispose
107 Removes all circular references in this NamedNodeMap and its
108 descendants so the objects can be claimed for garbage collection.
109 The objects should not be used afterwards.
110
111
112
113perl v5.28.0 2000-01-31 XML::DOM::NamedNodeMap(3)