using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.Data; using System.Xml.XPath; using System.IO; namespace TestXPath ... { class XMLOpretion ...{ /**////<summary> /// recieve xml return DataTable, Static Method ///</summary> /// <param name="url"> the path of xml document /// </parm> public static DataTable FillDT(string url) ...{ StreamReader sr = new StreamReader(url); XmlDataDocument xd = new XmlDataDocument(); xd.DataSet.ReadXml(sr); DataTable dt=xd.DataSet.Tables[0]; xd = null; sr.Close(); return dt; } /**////<summary> /// recieve xml,the XPath , return XPathNodeIterator, Static Method ///</summary> /// <param name="url"> the path of xml document /// </parm> /// <param name="XPathSelect">the XPath select sentence</param> public static XPathNodeIterator XPathIter(string url, string XPathSelect) ...{ StreamReader sr = new StreamReader(url); XPathDocument doc = new XPathDocument(sr); XPathNavigator myNav = doc.CreateNavigator(); XPathNodeIterator myIter = myNav.Select(XPathSelect); doc = null; sr.Close(); return myIter; } }}