I am attempting to retrieve the value of a single node in an XML document.
Here are a couple of methods I have tried which don't work:
public class Location
{
private String latitude;
public void updateLocation(String woeid)
{
String query = String.Format("http://weather.yahooapis.com/forecastrss?w={0}", woeid);
XmlDocument weatherData = new XmlDocument();
weatherData.Load(query);
XmlNode channel = weatherData.SelectSingleNode("rss").SelectSingleNode("channel");
XmlNamespaceManager man = new XmlNamespaceManager(weatherData.NameTable);
man.AddNamespace("geo:lat", "http://xml.weather.yahoo.com/ns/rss/1.0");
latitude = channel.SelectSingleNode("geo:lat", man).InnerText;
}
and this method, which also doesn't work:
public class Location
{
private String latitude;
public void updateLocation(String woeid)
{
String query = String.Format("http://weather.yahooapis.com/forecastrss?w={0}", woeid);
XmlDocument weatherData = new XmlDocument();
weatherData.Load(query);
XmlNode channel = weatherData.SelectSingleNode("rss").SelectSingleNode("channel");
latitude = channel.SelectSingleNode("item").SelectSingleNode("geo:lat").InnerText;
}
}
Why am I not able to get the value of "geo:lat"?