Please how can i get only one element data from this xml soap web service response? (for example: <location>). Thank you

<string><?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>
  <Location>Madrid / Cuatro Vientos, Spain (LEVS) 40-23N 003-47W 687M</Location>
  <Time>Dec 22, 2012 - 03:00 AM EST / 2012.12.22 0800 UTC</Time>
  <Wind> Calm:0</Wind>
  <Visibility> less than 1 mile:0</Visibility>
  <SkyConditions> obscured</SkyConditions>
  <Temperature> 50 F (10 C)</Temperature>
  <DewPoint> 50 F (10 C)</DewPoint>
  <RelativeHumidity> 100%</RelativeHumidity>
  <Pressure> 30.30 in. Hg (1026 hPa)</Pressure>
  <Status>Success</Status>
</CurrentWeather></string>

You can use Linq To XML.

string xmlStr = @"<?xml version=""1.0"" encoding=""utf-16""?>
 <CurrentWeather>
  <Location>Madrid / Cuatro Vientos, Spain (LEVS) 40-23N 003-47W 687M</Location>
  <Time>Dec 22, 2012 - 03:00 AM EST / 2012.12.22 0800 UTC</Time>
  <Wind> Calm:0</Wind>
  <Visibility> less than 1 mile:0</Visibility>
  <SkyConditions> obscured</SkyConditions>
  <Temperature> 50 F (10 C)</Temperature>
  <DewPoint> 50 F (10 C)</DewPoint>
  <RelativeHumidity> 100%</RelativeHumidity>
  <Pressure> 30.30 in. Hg (1026 hPa)</Pressure>
  <Status>Success</Status>
</CurrentWeather>";

var doc = XDocument.Parse(xmlStr);
string location = doc.Root.Element("Location").Value;
Console.WriteLine(location);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.