Tuesday, November 2, 2010

XML NODE TRAVERSE IN ASP.NET

public void TravelNode(XmlNode n)
{
TravelNode(n, 0);
}

public void TravelNode(XmlNode n, int i)
{

foreach (XmlAttribute attr in n.Attributes)
{

string v = attr.Name;
string na = attr.Value;
if (v == "Code")
{
status = "Not Delievered";
break;

}
else
{
status = "Delievered";

}

}

foreach (XmlNode nod in n.ChildNodes)
{

TravelNode(nod, i + 1);
}

}

protected void Button1_Click(object sender, EventArgs e)
{
String      dr="<?xml%20version=\"1.0\"%20encoding=\"ISO-8859-1\"?><!DOCTYPE%20REQUESTCREDIT%20SYSTEM%20\"http://107.10.10.01/dtd/requestcredit.dtd\"%20>";

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.LoadXml(dr);

TravelNode(xmlDoc.DocumentElement);
}

0 comments:

Post a Comment