Name
NamedNodeMap
Synopsis
The NamedNodeMap
interface defines a collection
of nodes that may be looked up by name or by namespace URI and local
name. It is unrelated to the java.util.Map
interface. Use getNamedItem( )
to look for and
return a node whose getNodeName( )
method returns
the specified value. Use getNamedItemNS( )
to look
for and return a node whose getNamespaceURI( )
and
getLocalName( )
methods return the specified
values. A NamedNodeMap
is a mapping from names to
nodes, and does not order the nodes in any particular way.
Nevertheless, it does impose an arbitrary ordering on the nodes and
allow them to be looked up by index. Use getLength(
)
to find out how many nodes are contained in the
NamedNodeMap
, and use item( )
to obtain the Node
object at a specified index.
If a NamedNodeMap
is not read-only, you can use
removeNamedItem( )
and removeNamedItemNS(
)
to remove a named node from the map, and you can use
setNamedItem( )
and setNamedItemNS(
)
to add a node to the map, mapping to it from its name or
its namespace URI and local name.
NamedNodeMap
objects are
“live,” which means that they
immediately reflect any changes to the document tree. For example, if
you obtain a NamedNodeMap
that represents the
attributes of an element, and then add a new attribute to that
element, the new attribute is automatically available through the
NamedNodeMap
: you do not need to obtain a new
NamedNodeMap
to get the modified set of
attributes.
NamedNodeMap
is returned only by relatively obscure ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.