Search in XML file using C# ASP.Net/ loop through XML nodes using C#
This example use to find out the name and pin of a particular employee ...by passing empcode as parameter
String Name;
int pin;
public void fillfromXML(string Code)
{
doc.Load(Server.MapPath(@"Address.xml"));
XmlNodeList addlst = doc.SelectNodes("Address/add/Empcode");
foreach (XmlNode Empcode in addlst)
{
if (Empcode.InnerText == Code)
{
string Name = Empcode.ParentNode.ChildNodes[2].InnerText;
int pin = Convert.ToInt32(Empcode.ParentNode.ChildNodes[3].InnerText);
}
}
Any query feel free to ask.......
}
