XML Problem
-
Hi All, Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it. Thanks, Inder....
Load the xml with the XmlDocument and use xpath to get the nodes. Iterate those nodes the read the attribute. Example:
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("XMLFile.xml"); XmlNodeList selectedNodes = xmlDoc.SelectNodes("//Store[@Stores>30]"); foreach (XmlNode item in selectedNodes) { Console.WriteLine(item.Attributes["name"].Value); } Console.ReadLine();
My xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Stores>
<Store name="Name1" store="10"/>
<Store name="Name2" store="20"/>
<Store name="Name3" store="30"/>
<Store name="Name4" store="40"/>
</Stores> -
Hi All, Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it. Thanks, Inder....
Don't cross post!:mad: You have already asked this question in the C# forum, which is more appropriate than the ASP.NET forum but should have been placed in the XML forum
I know the language. I've read a book. - _Madmatt