Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2015 17:44
Show Gist options
  • Select an option

  • Save anonymous/e2d78b44e1d0cbf1fa0a to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/e2d78b44e1d0cbf1fa0a to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.Xml.Linq;
namespace ExampleConsoleApp
{
class Program
{
static void Main(string[] args)
{
const string xml = "<weather><temperature>30C</temperature><foo>bar</foo></weather>";
var xdoc = XDocument.Parse(xml);
var temperature = xdoc.Descendants().Single(d => d.Name == "temperature").Value;
Console.WriteLine(temperature);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment