The examples in this section all use the following XML file:


        <?xml version="1.0" encoding="utf-8" standalone="yes"?>
            <customer id="123" status="archived">


The SelectXXX methods accept an XPath query string.

For example, the following finds the firstname node of an XmlDocument:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Text;
using System.IO;
class Program
    static void Main()
        XmlDocument doc = new XmlDocument();
        XmlNode n = doc.SelectSingleNode("customers/customer[firstname='Jack']");

The output:


Common XPath operators

//Recursively children
.Current node (usually implied)
..Parent node
:Namespace separator
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.