August 2003
Beginner to intermediate
600 pages
12h 57m
English
The two most commonly used node-insertion methods are the AppendChild method, which appends the specified node as the last child of the current node, and PrependChild, which prepends the specified node as the first child of the current node. Listing 11.21 creates two elements, adds one to the beginning of the root node's list, and adds another to the end of the root node's list.
C# XmlDocument doc = new XmlDocument(); doc.LoadXml("<root/>"); XmlElement firstChild = doc.CreateElement("", "First", ""); XmlElement lastChild = doc.CreateElement("", "Last", ""); doc.DocumentElement.PrependChild(firstChild); doc.DocumentElement.AppendChild(lastChild); doc.Save("out.xml"); VB Dim doc As ... |
Read now
Unlock full access