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 ...

Get Microsoft® .NET Compact Framework Kick Start 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.