XML Sitemap呈现为纯文本

Wei*_*sen 2 xml sitemap

我有一个XML Sitemap,在浏览器中访问时需要正确呈现。

请参见下面的代码。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<urlset
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
http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"   
>
<url>
    <loc>https://www.brideonline.ru/_____PassioanteLady.html</loc>
    <xhtml:link rel="alternate" hreflang="ru-us" href="https://www.brideonline.ru/profile.php?Language=Russian&#038;ID=_____PassioanteLady&#038;Language1=1"/>
    <changefreq>monthly</changefreq>
    <priority>0.1</priority>
</url>
<url>
    <loc>https://www.brideonline.ru/___Alisa___.html</loc>
    <xhtml:link rel="alternate" hreflang="ru-us" href="https://www.brideonline.ru/profile.php?Language=Russian&#038;ID=___Alisa___&#038;Language1=1"/>
    <changefreq>monthly</changefreq>
    <priority>0.1</priority>
</url>
</urlset>
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试在浏览器上访问它时,它仅显示为纯文本。

非常感谢任何帮助/解释为何将其呈现为纯文本。

谢谢。

Wei*_*sen 5

因此,经过数小时的谷歌搜索并进行了大量尝试和错误之后,我设法通过以下链接解决了我的问题:Google多语言站点地图问题

通过更改声明(使用http://www.w3.org/1999/xhtml):

<urlset 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 http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
Run Code Online (Sandbox Code Playgroud)

为此(使用http://www.w3.org/TR/xhtml11/xhtml11_schema.html):

<urlset 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 http://www.w3.org/TR/xhtml11/xhtml11_schema.html http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html">
Run Code Online (Sandbox Code Playgroud)

现在,当在浏览器中访问XML文件时,它现在返回XML格式而不是纯文本。

希望这可以帮助其他有需要的人。:)

  • 这样可以在浏览器上查看正确的XML格式,但是Google无法识别站点地图,将站点地图提交给Google搜索控制台时出现此错误:“您的站点地图或站点地图索引文件未正确声明名称空间。行:2“ (2认同)