XPathNavigator.PrependChild returns XmlWriter to create a new child node
Imports System
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim document As XmlDocument = New XmlDocument()
document.Load("domainBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToChild("bookstore", "http://www.domain.com/books")
navigator.MoveToChild("book", "http://www.domain.com/books")
Dim pages As XmlWriter = navigator.PrependChild()
pages.WriteElementString("pages", "100")
pages.Close()
Console.WriteLine(navigator.OuterXml)
End Sub
End Class
Related examples in the same category