|
Listing 21-11 extracted from chapter XML
Listing 21-10< > Listing 21-12
This listing can be compiled with the command line: csc.exe /target:exe Example_21_11.cs Errors: 0 Warnings: 0
Example_21_11.cs
using System.Xml.XPath;
class Program {
static void Main() {
XPathDocument document = new XPathDocument(@"C:\books.xml");
XPathNavigator navigator = document.CreateNavigator();
XPathNodeIterator iterator =
navigator.Select(@"/bookstore/book/author/first-name");
while( iterator.MoveNext() )
System.Console.WriteLine("<" + iterator.Current.Name + ">" +
iterator.Current.Value);
}
}
Copyright Patrick Smacchia 2006 2007
|