How to get the value of backgroundGradientTop node without using its name .In my case the xml is dynamic .so icant dpeend on node name .but the structure is same.So i have to get it without using its name
System.Xml.XmlElement root = XmlDoc.DocumentElement;
System.Xml.XmlElement valuelist = (System.Xml.XmlElement)root.ChildNodes[0].ChildNodes[0];
System.Xml.XmlElement settingslist = (System.Xml.XmlElement)root.ChildNodes[0].ChildNodes[0].ChildNodes[0];
value = valuelist.ChildNodes[0].InnerText.Trim();//returns the value in <backgroundGradientTop>
categoryname = valuelist.Name;//returns node name
settingsname = settingslist.Name;//returns node name
Thanks & Regards,
Arun Sunny.
Marked as answer by itssunny on Feb 07, 2012 04:21 AM
ItsSunny
Contributor
2163 Points
676 Posts
reading value from xml document
Feb 06, 2012 07:01 AM|LINK
i am using followiing xml in xmldocument in a webmethod
<root>
<background>
<color>
<backgroundGradientTop>
52377
</backgroundGradientTop>
</color>
</background>
</root>
How to get the value of backgroundGradientTop node without using its name .In my case the xml is dynamic .so icant dpeend on node name .but the structure is same.So i have to get it without using its name
Arun Sunny.
Muhammad Fak...
Contributor
2268 Points
511 Posts
Re: reading value from xml document
Feb 06, 2012 08:44 AM|LINK
This will help you
http://support.microsoft.com/kb/307548
ask me if there is any problem
If you feel it helps, Mark as answered so that it can help others to find solution.
For Any further questions, please contact me.
ItsSunny
Contributor
2163 Points
676 Posts
Re: reading value from xml document
Feb 06, 2012 08:50 AM|LINK
i am using xmldocument like this
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.LoadXml(AddSettingsXml);
i need to get node name and node value from xmldocument
Arun Sunny.
ItsSunny
Contributor
2163 Points
676 Posts
Re: reading value from xml document
Feb 07, 2012 04:20 AM|LINK
Got it
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.Load(Server.MapPath("test.xml"));
string categoryname;
string settingsname;
string value;
System.Xml.XmlElement root = XmlDoc.DocumentElement;
System.Xml.XmlElement valuelist = (System.Xml.XmlElement)root.ChildNodes[0].ChildNodes[0];
System.Xml.XmlElement settingslist = (System.Xml.XmlElement)root.ChildNodes[0].ChildNodes[0].ChildNodes[0];
value = valuelist.ChildNodes[0].InnerText.Trim();//returns the value in <backgroundGradientTop>
categoryname = valuelist.Name;//returns node name
settingsname = settingslist.Name;//returns node name
Arun Sunny.