Fast select by ID using XPath : XPathNodeIterator « XML « C# / CSharp Tutorial






/*
<orders>
  <order orderno="id10952" date="4/15/96" shipAddress="Str. 57"/>
  <order orderno="id2" date="6/13/95" shipAddress="Road  2312"/>   
</orders>
*/
using System;
using System.Xml; 
using System.IO;
using System.Text;
using System.Xml.XPath;
class MainClass{
  public static void Main(string[] args){
        XmlDocument doc = new XmlDocument();
        doc.Load("d:/orders.xml");
        //Fast select by ID using XPath
        XPathNodeIterator ni = nav.Select("id('id2')");
        if (ni.MoveNext())
          Console.WriteLine(ni.Current.GetAttribute("shipAddress", ""));
          

  }

}








30.24.XPathNodeIterator
30.24.1.Fast select by ID using XPath