XPathNavigator.ReplaceSelf (XmlReader) replaces the current node with the contents of the XmlReader object specified.
Imports System
Imports System.IO
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")
navigator.MoveToChild("price", "http://www.domain.com/books")
Dim pages As XmlReader = XmlReader.Create(New StringReader("<pages xmlns='http://www.domain.com/books'>100</pages>"))
navigator.ReplaceSelf(pages)
Console.WriteLine("Position after delete: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)
End Sub
End Class
Related examples in the same category