using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
publicclass MainClass {
publicstaticvoid Main() {
XPathDocument doc = new XPathDocument("books.xml");
XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator();
XPathNodeIterator iter = nav.Select("/bookstore/book");
while (iter.MoveNext()) {
XPathNodeIterator newIter = iter.Current.SelectDescendants(XPathNodeType.Element, false);
while (newIter.MoveNext())
Console.WriteLine(newIter.Current.Name + ": " + newIter.Current.Value);
}
Console.WriteLine("Total Cost = " + nav.Evaluate("sum(/bookstore/book/price)"));
}
}