This question is the same as XML sitemap remove xmlns from url tag but that one was never answered . Right now my xml returns as follow
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url xmlns="">
<loc>https://www.localhost.com/J-B-Lansing-Co-CA/1/Hsuhsus</loc>
</url>
<url xmlns="">
<loc>
https://www.localhost.com/J-B-Lansing-Co-CA/2/Swhuwhsw-wshwshusws
</loc>
</url>
</urlset>
I am focused on this part here <url xmlns="">
I need to remove the xmlns part and have been unsuccessful . My code is as follows
[Route("sitemap")]
public async Task<ContentResult> SiteMap()
{
var result = await _homeRepository.URLMapper();
XNamespace nsSitemap = "http://www.sitemaps.org/schemas/sitemap/0.9";
var urlSet = new XElement(nsSitemap + "urlset",
result.Select(x =>
new XElement("url",
new XElement("loc", x.URL))));
return new ContentResult
{
ContentType = "text/xml",
Content = urlSet.ToString(),
StatusCode = 200
};
}
The result url mapper simply returns a list of urls from the database . Any suggestions would be great .