(Xml) Reading a Selected Node Attributes [modified]
-
right usually when i read Xml I do it like this :
XmlDocument XmlDoc = new XmloDocument();
XmlDoc.Load("C:\\Example.xml");
XmlNodeList XmlnodeyList = XmlDoc.SelectNodes("Xml/Node");
foreach(XmlNode Nodey in XmlNodeyList)
{
listView1.Items.Add((string.format("{0}", Nodey.Attributes["ExampleNode"].Value.ToString())));
}Now that then populates a listview with the nodes in the xml file, I now have been pulling my hair out trying get it to red the second area of the nodes for example in the xml file :
Sorry CodeProject Wouldent display it properally :)
i want it to read the SecondNode but since i have say 4 of them all diffrent i want it to then read it and make a label have the secondnode text from the listview selected item , Here is the code i wrote for it :
string Name = listView1.SelectedItems[0].ToString();
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.Load(XmlPath);
XmlNode Nodey = XmlDoc.SelectSingleNode(string.Format("Xml/Node/{0}", Name));
label1.Text = (string.Format("{0}", Nodey.Attributes["SecondNode"].Value.ToString()));so on click from the listview it gets the second node etc , any help wouyld be grand guys ! Jed
modified on Saturday, April 3, 2010 5:11 AM