Sunday, 20 July 2014

Trying to get node value from XML [duplicate]




This question already has an answer here:




I cant get the woe id properly from this xml repsonse:



<places xmlns="http://ift.tt/1mCAy11"xmlns:yahoo="http://ift.tt/1apoFAW" yahoo:start="0" yahoo:count="1" yahoo:total="16">

<place yahoo:uri="http://ift.tt/1qtVtG3" xml:lang="en-US">
<woeid>20070051</woeid>
<placeTypeName code="8">Oblast</placeTypeName>
<name>Varna</name>
<country type="Country" code="BG" woeid="23424771">Bulgaria</country>
<admin1 type="Oblast" code="BG-03" woeid="20070051">Varna</admin1>
<admin2 />


...


Here is my code:



XDocument XResult = XDocument.Parse(e.Result);

XElement WOEID = XResult.Elements(XName.Get("woeid")).FirstOrDefault();

GetWeatherConditionFor(WOEID.Value.ToString());


XResult is filled corectly with the XML but cant get the value. Whys that?


No comments:

Post a Comment