+4  A: 

You need to add it to the top level element in the document (the root):

map.Root.Add(...)
Erv Walter
This works. Thank you!
Zack Peterson
I struggled with this for awhile!!
MattGWagner
+5  A: 

Why not fill it out completely with another xml literal hole?

Dim map As XDocument = <?xml version="1.0" encoding="UTF-8"?>
                       <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&gt;
                           <%= From n In Nodes.Cast(Of Node)() _
                               Select <url>
                                          <loc><%= AbsoluteRoot + Url.RouteUrl("IdOnly", New With {.id = n.Id}) %></loc>
                                      </url> %>
                       </urlset>
JaredPar
This works. Thank you!
Zack Peterson