c# - How to Upgrade to the new Yahoo weather API? -


for time have been using yahoo weather api current day temperature , forecasts statistics in .net application in c#. apparently yahoo updated api , application fails data.

i using xml document data

    xmldocument doc = new xmldocument();     doc.load("http://xml.yahooapis.com/forecastrss?w=" + woeid + "&u=c");     xmlnamespacemanager ns = new xmlnamespacemanager(doc.nametable);     ns.addnamespace("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0");      xmlnode nod = doc.selectsinglenode("/rss/channel/link", ns);     link = nod.innertext;     ....more nodes selected.... 

and xml nodes , values store them in database.

what changes have make application work new api?

first of need change url asking forecast from

 doc.load("http://xml.yahooapis.com/forecastrss?w=" + woeid + "&u=c"); 

to

      query="select%20*%20from%20weather.forecast%20where%20woeid%20%3d%20"+ woeid             + "%20and%20u=%27c%27";       doc.load("https://query.yahooapis.com/v1/public/yql?q="+query+"&format=xml                  &env=store%3a%2f%2fdatatables.org%2falltableswithkeys"); 

then need change nodes path because new xml document different old one.

change from

xmlnode nod = doc.selectsinglenode("/rss/channel/link", ns); 

to

xmlnode nod = doc.selectsinglenode("/query/results/channel/link", ns); 

and should working fine.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -