Mega Code Archive
XPathNavigator Evaluate evaluates XPath expression and returns typed result
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("books.xml");
XPathNavigator navigator = document.CreateNavigator();
Double total = (double)navigator.Evaluate("sum(descendant::book/price)");
Console.WriteLine("Total price for all books: {0}", total.ToString());
}
}
/*
C#
A
B
8.99
XML
D
E
11.99
*/