Simple Application of xpath (source code)

Source: Internet
Author: User
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;
}

}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.