how to get data from xml?
-
Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama
-
Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama
try with
nameNode.NextSibling
or else go with xmlreader
-
Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama
You can use XPath to extract the node(s) you are looking for
doc.SelectNodes("timezone[text=" + _name + "]");
(May not be 100% correct, but you get the idea)
I know the language. I've read a book. - _Madmatt
-
Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama
_name is not a string, it is an XmlNodeList. That shouldn't even compile. Loop through the NodeList and for each node get the InnerText. You can find an example on the first page of google search results for "XmlNodeList". Also, you might want to revise your XML schema. If you want each text element to be associated with the value element following it they should be encapsulated in another element. Order is not always guaranteed in XML parsing.
-
Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama
Thanks for sharing the procedure and the code for xml,ir was really hlpfull for me as i am new to it. Reverse Phone Lookup [Availing Payday Loans](http://www.paydayloansolutions.net/blog/top-6-reasons-for-availing-pay-day-loans
)