【发布时间】:2016-07-22 22:21:09
【问题描述】:
我有一个有效的 sitemap.xml 文件。当我尝试将此文件作为 sitemap.xml 提供时,就会出现问题。我收到以下错误:
This page contains the following errors:
error on line 1 at column 95: Extra content at the end of the document
Below is a rendering of the page up to the first error.
当我从浏览器检查 /sitemap.xml 时,每个元素标记都会添加到其中。
<url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
the rest
</url>
这是我从控制器返回文件的方式:
XmlDocument xml = new XmlDocument();
xml.Load(@"C:\sitemap.xml");
return Content(xml.DocumentElement.InnerXml, "application/xml");
这是我拥有并尝试返回的文件的示例
<?xml version="1.0" encoding="utf-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
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">
<url>
<loc>LINK</loc>
</url>
THE REST OF URLS
</urlset>
我尝试将“application/xml”切换为“text/xml”,但没有解决这个问题。我没有正确使用 XmlDocument 还是我没有完全理解 return Content() 会发生什么?
感谢任何帮助。
谢谢
【问题讨论】:
标签: asp.net xml asp.net-mvc-4 sitemap nopcommerce