<myData> <data key="abc" value="11 " /> <data key="def" value="458" /> <data key="ghi" value="89" /> <data key="jkl" value="5" /> <data key="mno" value="563" /> <data key="pqr" value="200" /> </myData>
XmlNode
var root = new XmlDocument(); root.Load(@"samplexml.xml"); XmlNode nodeObj = root.SelectSingleNode("/myData/add[@key=abc]"); string str1= nodeObj.Attributes["value"].Value;
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { //Create the XmlDocument. XmlDocument doc = new XmlDocument(); doc.Load("books.xml"); //Display all the book titles. XmlNodeList elemList = doc.GetElementsByTagName("data"); for (int i=0; i < elemList.Count; i++) { Console.WriteLine(elemList[i].InnerXml); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)