Mega Code Archive

 
Categories / C# / XML
 

XPathNavigator MoveToFollowing moves XPathNavigator to the element with the local name and namespace URI

using System; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; using System.Xml.XPath; public class MainClass {     public static void Main()     {         XPathDocument document = new XPathDocument("domainBooks.xml");         XPathNavigator navigator = document.CreateNavigator();         navigator.MoveToFollowing("book", "http://www.domain.com/books");         XPathNavigator boundary = navigator.Clone();         boundary.MoveToFollowing("first-name", "http://www.domain.com/books");         navigator.MoveToFollowing("price", "http://www.domain.com/books", boundary);         Console.WriteLine("Position (after boundary): {0}", navigator.Name);         Console.WriteLine(navigator.OuterXml);         navigator.MoveToFollowing("title", "http://www.domain.com/books", boundary);         Console.WriteLine("Position (before boundary): {0}", navigator.Name);         Console.WriteLine(navigator.OuterXml);     } }