XPathNavigator.ReadSubtree reads the current node and its child nodes.
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.MoveToChild("bookstore", "http://www.domain.com/books");
navigator.MoveToChild("book", "http://www.domain.com/books");
XmlReader reader = navigator.ReadSubtree();
while (reader.Read())
{
Console.WriteLine(reader.ReadInnerXml());
}
reader.Close();
}
}
Related examples in the same category