C# .NET - how to read the xml node attributes?
Asked By chitra ganapathy on 11-Dec-12 12:13 AM
I want to get the attributes values in xml, I used the following code
XmlDocument RSSXml = new XmlDocument();
RSSXml.Load("http://weather.yahooapis.com/forecastrss?w=29223178&u=f");
XmlNodeList RSSNodeList = RSSXml.SelectNodes("rss/channel");
foreach (XmlNode RSSNode in RSSNodeList)
{
XmlNode RSSSubNode;
RSSSubNode = RSSNode.SelectSingleNode("title");
string title = RSSSubNode != null ? RSSSubNode.InnerText : "";
RSSSubNode = RSSNode.SelectSingleNode("link");
string link = RSSSubNode != null ? RSSSubNode.InnerText : "";
RSSSubNode = RSSNode.SelectSingleNode("description");
string desc = RSSSubNode != null ? RSSSubNode.InnerText : "";
lbl_title.Text = title;
lbl_link.Text = link;
lbl_desc.Text = desc;
}
Its working well, but I want to get the yweather:location node attributes values. can you please help in this.