title: C# Xdocument Xml get Element
body: <p>I have a xml file that looks like this:</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
   &lt;s:Body&gt;
    &lt;GetAllArticlesResponse xmlns="http://www.borger.dk/2009/WSArticleExport/v1"&gt;
       &lt;GetAllArticlesResult xmlns:a="http://www.borger.dk/2009/WSArticleExport/v1/types" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
          &lt;a:ArticleDescription&gt;Test 1&lt;/a:ArticleDescription&gt;
          &lt;a:ArticleDescription&gt;Test 2&lt;/a:ArticleDescription&gt;
        &lt;/GetAllArticlesResult&gt;
    &lt;/GetAllArticlesResponse&gt;
   &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>I'm trying to get all the articles, but can't get it to work.</p>
  
  <pre><code> XDocument doc = XDocument.Parse(soapResult);
   IEnumerable&lt;XElement&gt; articles = doc.Root.Descendants("a:ArticleDescription");
  </code></pre>
  
  <p>This has work before, but because the element name as a : then it fails..</p>
  
  <p>Any idea how to fix this.</p>
  
  <p>Thanks for all the inputs.</p>
  
  <p>I ended with::</p>
  
  <pre><code>                XNamespace a = "http://www.borger.dk/2009/WSArticleExport/v1/types";
                  XDocument doc = XDocument.Parse(soapResult);
                  IEnumerable&lt;XElement&gt; articles = doc.Root.Descendants(a + "ArticleDescription");
  
                  List&lt;Article&gt; article = articles.Select(m =&gt; new Article()
                  {
                      ArticleID = m.Element(a + "ArticleID").Value.ToString(),
                      ArticleTitle = m.Element(a + "ArticleTitle").Value.ToString(),
                      ArticleUrl = m.Element(a + "ArticleUrl").Value.ToString(),
                      LastUpdated = m.Element(a + "LastUpdated").Value.ToString(),
                      PublishingDate = m.Element(a + "PublishingDate").Value.ToString()
                  }).ToList();
                  json = JsonConvert.SerializeObject(article);
  </code></pre>