title: How to read a sitemap using VB.NET
body: <p>I have been trying to open the following XML file in VB.NET using the Linq library.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="http://wegotflash.com/sitemap.xsl"?&gt;
  &lt;urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;
      &lt;url&gt;
          &lt;loc&gt;http://wegotflash.com&lt;/loc&gt;
          &lt;lastmod&gt;2012-02-19&lt;/lastmod&gt;
          &lt;changefreq&gt;daily&lt;/changefreq&gt;
          &lt;priority&gt;1&lt;/priority&gt;
      &lt;/url&gt;
      &lt;url&gt;
          &lt;loc&gt;http://wegotflash.com/cat/1/shooter/newest-1&lt;/loc&gt;
          &lt;lastmod&gt;2012-02-19&lt;/lastmod&gt;
          &lt;changefreq&gt;daily&lt;/changefreq&gt;
          &lt;priority&gt;0.8&lt;/priority&gt;
      &lt;/url&gt;
  &lt;/urlset&gt;
  </code></pre>
  
  <p>The code that I'm using works with normal XML files, but whenever I add the <code>xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"</code> attribute to the root node, nothing is getting returned by the application. Here is the VB.NET code that is reading the XML file:</p>
  
  <pre><code>Dim XMLFile As XDocument = XDocument.Load(TextBox1.Text)
  For Each url As XElement In XMLFile.Descendants("url")
      If url.HasElements Then
          MessageBox.Show(url.Element("loc").Value)
      End If
  Next
  </code></pre>