Pulling XML Elements in C# Via an API Feed -


To demonstrate the weather condition, I am trying to pull some elements from a weather API. First of all, I'm trying to catch the name of the weather station, which is & lt; In the feed inside the IoCo> element & lt; Station>.

Here is the feed XML file that I am trying to drag:

I & lt; ICO> Data>?

Use System.Xml.Linq , like this: < / P>

  XDocument.Load (@ "http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=94107") .Root .Element ("Element ( "Airport"). Element ("Station") Element ("ICO"). Value  

Or, if you want to get value for all the station,

< Pre> XDocument.Load (@ "http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=94107") .Root .Element ("Element" ("Station" Select "Elements" ("Station"). (S = & gt; s.Element ("Ioco"). Value)

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -