The hypothetical xml file contains the following content ..
<? Xml version = "1.0" encoding = "UTF-8"?>
<A>
<B>
<C c1 = ""> JAPAN </C>
</B>
<B>
<C c1 = "Taipei"> TAIWAN </C>
<C c1 = "Tainan"> TAIWAN </C>
</B>
<B>
<C c1 = "Beijing"> CHINA </C>
</B>
</A>
How to retrieve the internal or external content at a specific xml vertex... there is a simple example below... using xpath...
Part of asp.net (c #) Programs
Using System;
Using System. Collections;
Using System. Configuration;
Using System. Data;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. HtmlControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Xml;
Public partial class XPATH: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
XmlDocument xmldoc = new XmlDocument ();
Xmldoc. Load (Server. MapPath ("XML. xml"); // loads the xml Parser
String xPathExpression1 = "/A/B/C [. = 'Taiwan ']"; // find 'Taiwan' in the node'
XmlNodeList nodelist = xmldoc. SelectNodes (xPathExpression1); // multi node
String xPathExpression2 = "/A/B/C [@ c1 = 'taibei ']"; // find the node with 'taibei'
XmlNode node = xmldoc. SelectSingleNode (xPathExpression2); // single node
// Outputs the result: TAIWAN
Response. Write (node. OuterXml );
Response. Write ("<p> ");
// Result: Tainan, Taipei
Foreach (XmlNode item in nodelist)
{
Response. Write (item. Attributes ["c1"]. Value );
Response. Write ("<br/" + "> ");
}
}
}
The result of the rows: