I am getting this error on google search console. I tried bunch of things but nothing worked. Any suggestion if i am missing something.
Description: Your Sitemap or Sitemap index file doesn't properly declare the namespace.
Example: Your Sitemap or Sitemap index file doesn't declare the expected namespace: http://www.sitemaps.org/schemas/sitemap/0.9 Tag: urlset
This is what i see on the sitemap:
<?xml version="1.0" encoding="utf-8" standalone="yes"?><urlset xmlns:Xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
My Code:
public XmlSitemapResult(IEnumerable<ISitemapItem> items)
{
_items = items;
}
public override void ExecuteResult(ControllerContext context)
{
string encoding = context.HttpContext.Response.ContentEncoding.WebName;
XDocument sitemap = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement("urlset", new XAttribute(XNamespace.Xmlns.GetName("Xmlns"), "http://www.sitemaps.org/schemas/sitemap/0.9"),
from item in _items
select CreateItemElement(item)
)
);
context.HttpContext.Response.ContentType = "text/xml";
context.HttpContext.Response.Flush();
context.HttpContext.Response.Write(sitemap.Declaration + sitemap.ToString());
}