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(); 

```
Use XElement.Parse(string text) method to do this.

Example:

```
string xmlString = @"<poi>
              <city>stockholm</city>
              <country>sweden</country>
              <gpoint>
                <lat>51.1</lat>
                <lng>67.98</lng>
              </gpoint>
          </poi>";
        try
        {
            XElement x = XElement.Parse(xmlString);
            var latLng = x.Element("gpoint");

            Console.WriteLine(latLng.Element("lat").Value);
            Console.WriteLine(latLng.Element("lng").Value);
        }
        catch
        {
        }

```

Hope this helps!