Question: what is the simplest way to parse the lat and long out of the following xml fragment. There is no namespace etc.

It is in a string variable. not a stream.

```
<poi>
      <city>stockholm</city>
      <country>sweden</country>
      <gpoint>
        <lat>51.1</lat>
        <lng>67.98</lng>
      </gpoint>
</poi>

```

everything I have read so far is waaaaay too complex for what should be a simple task
e.g.
[Link](https://web.archive.org/web/20160829021356/http://geekswithblogs.net:80/kobush/archive/2006/04/20/75717.aspx)

I've been looking at the above link

Surely there is a simpler way to do this in .net?

Answer: 
Using Linq for XML:

```
   XDocument doc= XDocument.Parse("<poi><city>stockholm</city><country>sweden</country><gpoint><lat>51.1</lat><lng>67.98</lng></gpoint></poi>");

    var points=doc.Descendants("gpoint");

    foreach (XElement current in points)
    {
        Console.WriteLine(current.Element("lat").Value);
        Console.WriteLine(current.Element("lng").Value);
    }

    Console.ReadKey(); 

```
If you can use LINQ for XML you can read those two values straight forward like this:

```
var doc = XDocument.Parse("...");
var point = doc.Element("poi").Element("gpoint");
Console.WriteLine("Lat: {0}, Lng: {1}",
    point.Element("lat").Value,
    point.Element("lng").Value);

```

If you need them as double you have to convert them:

```
double lat = Convert.ToDouble(point.Element("lat").Value,
                 CultureInfo.InvariantCulture);

```

Don't forget to specify a culture that uses a dot for fractions. Otherwise this would yield 511.0 as latitude.