Writing Nodes
You have the option of creating an XML document by writing code that creates specific objects as you construct the XML. For example, you can call the CreateElement method to create an XmlElement object that you can deal with. However, similar to what we did when showing how to read an XML document, you can choose to write code that writes an XML document using XmlNodes only.
The XmlDocument class provides the method CreateNode that can be used for this purpose. Actually, this method has several versions depending on your needs. The version used in the following code example takes three arguments. The first is a NodeType (defined in Chapter 33, “Reading XML,” in Table 33.1) that represents the type of node to create. The second parameter ...
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