I\'m trying to create a sitemap using Linq to Xml, but am getting an empty namespace attribute, which I would like to get rid of. e.g.
XNamespace ns = \"http
I stumbled across this post while dealing with a similar problem in VB.NET. I was using XML literals and it took me some searching to figure out how to make this solution work with the XML literal construction and not just the functional construction.
The solution is to import the XML namespace at the top of the file.
Imports
And then prefix all of my XML literals in the query expression with the imported namespace. This removes the empty namespace that were appearing on the elements when I saved my output.
Dim output As XDocument =
0
<%= From tg In termGroups _
Select
<%= From t In tg _
Select <%= t %> %>
%>
output.Save("C:\thesaurus.xml")
I hope this helps someone. Despite bumps in the road like this, the XLinq API is pretty darn cool.