Inserting XmlNodes
It is important to remember that the XmlNode creation method creates an XmlNode only in the context of the current document. It does not, however, add the XmlNodes to the document. You must explicitly insert the nodes into the document tree. The XmlNode class provides several methods for adding nodes to the document tree.
Before we begin discussing the insertion methods, let's talk about which nodes can contain other nodes. Not all nodes are container nodes, and not all container nodes can contain every node type. For example, an XmlAttribute node is a container node that can contain only XmlText nodes. It cannot contain an XmlProcessingInstruction node. An InvalidOperationException is raised when a specified node cannot be ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access