XPathNavigator: Evaluate : XmlPathNavigator « XML « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » XML » XmlPathNavigator 
30.23.2.XPathNavigator: Evaluate
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.XPath;

class MainClass
{
    static void Main(string[] args)
    {
        string xml = "<Order>" +
                        "<Item>" +
                            "<Description>Some widget part</Description>" +
                            "<Price>12.99</Price>" +
                        "</Item>" +
                        "<Item>" +
                            "<Description>Another widget</Description>" +
                            "<Price>50.12</Price>" +
                        "</Item>" +
                    "</Order>";

        XmlDocument doc = new XmlDocument();
        doc.LoadXml(xml);

        XPathNavigator nav = doc.CreateNavigator();
        Console.WriteLine("Total price for this order is ${0}", nav.Evaluate("sum(Order/Item/Price)"));
    }
}
Total price for this order is $63.11
30.23.XmlPathNavigator
30.23.1.XPathNavigator: XPathNodeIterator with comparison
30.23.2.XPathNavigator: Evaluate
30.23.3.Create XPathNavigator object by calling CreateNavigator of XmlDocument
30.23.4.XPathNodeIterator from a select-node statement
30.23.5.Select a node
30.23.6.Get Node information by using XPathNavigator
30.23.7.Move to a child with XPathNavigator
30.23.8.Fast select by ID using XPathNavigator API
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.