Overview
The XmlNamedNodeMap
class represents a collection of named nodes. It's typically used to represent the child nodes of an element in an XML document. You can traverse the XmlNamedNodeMap
to access its children, and modify them.
Properties
-
Contains:
bool
- Indicates whether the node map contains any child nodes. -
Item:
XmlNode
- Returns the named node with the specified name. -
Parent:
XmlNode
- The parent node of the node map.
Methods
- Add(XmlNode node): Adds a child node to the node map.
- Remove(XmlNode node): Removes a child node from the node map.
- Contains(string name): Checks if the node map contains a named node with the given name.
- GetXmlDocument(): Returns the XML document that the node map is part of.
Example
using System.Xml;
// ...
XmlDocument doc = new XmlDocument();
XmlNode root = doc.CreateElement("root");
XmlNode node1 = doc.CreateElement("child1");
XmlNode node2 = doc.CreateElement("child2");
XmlNode node3 = doc.CreateElement("child3");
XmlNamedNodeMap namedNodes = root.OwnerDocument.CreateXmlNamedNodeMap(root);
namedNodes.Add(node1);
namedNodes.Add(node2);
namedNodes.Add(node3);