XML DOM | NamedNodeMap Object

XML DOM - NamedNodeMap Object


Hello folks! welcome back to a new section of our tutorial on XML DOM. In this tutorial post, we are going to be studying about the XML DOM NamedNodeMap Object.

The NamedNodeMap object represents the collection of nodes that can be accessed by name.

NamedNodeMap Object Attributes

The following table lists the attributes of the NamedNodeMap object -

AttributeTypeDescription
lengthunsigned longIt gives the number of nodes in this map. The range of valid child node indices is 0 to length-1 inclusive.


NamedNodeMap Object Methods

The following table lists the methods of the NamedNodeMap object -

S.No.Methods & Description
1getNamedItem ()

Retrieves the node specified by name.

2getNamedItemNS ()

Retrieves a node specified by local name and namespace URI.

3item ()

Returns the indexth item in the map. If index is greater than or equal to the number of nodes in this map, this returns null.

4removeNamedItem ()

Removes a node specified by name.

5removeNamedItemNS ()

Removes a node specified by local name and namespace URI.

6setNamedItem ()

Adds a node using its nodeName attribute. If a node with that name is already present in this map, it is replaced by the new one.

7setNamedItemNS ()

Adds a node using its namespaceURI and localName. If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one. Replacing a node by itself has no effect.



Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we will be studying about XML DOM NamedNodeMap length Property.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.