load the xml into an XmlDocument object, select out the node you want (delete some nodes you do not want), then useSystem.Data.DataSet someDataSet = new System.Data.DataSet();
someDataSet.ReadXml(new
System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(SomeNode.InnerXml)));SomeNode is the XmlNode you want
someDataSet.ReadXml(new
System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(SomeNode.InnerXml)));SomeNode is the XmlNode you want
<Authors>
<Author>
<name>Mark</name>
<price>2200</price>
</Author>
<Author>
<name>Jane</name>
<price>3500</price>
</Author>
<Author>
<name>Tom</name>
<price>4000</price>
</Author>
</Authors>testxml.aspx:
<%@ Import Namespace="System.Xml" %>
<script language="C#" runat="Server">
void Page_Load(Object sender, EventArgs e)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("authors.xml"));
XmlElement el = (XmlElement)xmldoc.SelectSingleNode("//Author[name='Jane']/price");
if (el != null)
Response.Write("Jane's price:" + el.InnerText);
else
Response.Write("Jane Not found"); el = (XmlElement)xmldoc.SelectSingleNode("//Author[name='Jack']/price");
if (el != null)
Response.Write("Jack's price:" + el.InnerText);
else
Response.Write("Jack Not found");
}
</script>