hi,plz help (how can i access to xml node)
-
i new to c#.net i want to access one node in xmlfile using c#.net . that node have child node (i want that child node values) i write my xml file like this < < <Ap <MP <UP < <gjsefgjkl<dfhtyxcvd<ioiopweri < in this i want to access the "add" child node value. i wrote c#.net code like this, "When i press Button the childnode("add") values r stored in listbox " plz change any modification in my code or plz give code how to access thatnode private void button1_Click(object sender, System.EventArgs e) { string filename = "C:\\C#program\\cs_programs\\singlenode\\bin\\Debug\\nodexml.xml"; XmlTextReader tr = new XmlTextReader(filename); XmlDocument doc = new XmlDocument(); while(tr.Read()) { foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) listBox1.Items.Add(tr.Value); } } Thanks
-
i new to c#.net i want to access one node in xmlfile using c#.net . that node have child node (i want that child node values) i write my xml file like this < < <Ap <MP <UP < <gjsefgjkl<dfhtyxcvd<ioiopweri < in this i want to access the "add" child node value. i wrote c#.net code like this, "When i press Button the childnode("add") values r stored in listbox " plz change any modification in my code or plz give code how to access thatnode private void button1_Click(object sender, System.EventArgs e) { string filename = "C:\\C#program\\cs_programs\\singlenode\\bin\\Debug\\nodexml.xml"; XmlTextReader tr = new XmlTextReader(filename); XmlDocument doc = new XmlDocument(); while(tr.Read()) { foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) listBox1.Items.Add(tr.Value); } } Thanks
I've answered this, please stop asking these questions and instead go and read any basic XPath tutorial.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
I've answered this, please stop asking these questions and instead go and read any basic XPath tutorial.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
hi thanks for answered, i try u r solution. but my cod eis not working plz check my code , let me know any thing wrong in my code. Plz help Thanks
Hi, Thanks, if u think it's good. otherwise sorry.
-
hi thanks for answered, i try u r solution. but my cod eis not working plz check my code , let me know any thing wrong in my code. Plz help Thanks
Hi, Thanks, if u think it's good. otherwise sorry.
foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) Well, to be honest, I see no sign that you've done anything I've told you to do, to date. Your nodes are still named addr1, addr2 and addr3, which means the above XPath will never return anything. If you want the add node, then you want to use SelectSingleNode, and if you can't work out that to select the add node you need //details/add, then there's a serious problem here.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) Well, to be honest, I see no sign that you've done anything I've told you to do, to date. Your nodes are still named addr1, addr2 and addr3, which means the above XPath will never return anything. If you want the add node, then you want to use SelectSingleNode, and if you can't work out that to select the add node you need //details/add, then there's a serious problem here.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Thanks
Hi, Thanks, if u think it's good. otherwise sorry.