XML Sitemap rendering as plain text

帅比萌擦擦* 提交于 2021-01-27 07:40:47

问题


I have an XML Sitemap that needs to be rendered properly when accessed on a browser.

See code below.

<?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>

However, when I try accessing it on a browser, it only shows as plain text.

Any help/explanation why it renders as plain text is very much appreciated.

Thank you.


回答1:


So after many hours of googling and doing a lot of trial and errors, I managed to fix my problem with the help of this link: Google multilingual sitemap issue

By changing the declaration from this (using 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">

to this (using 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">

Now when the XML file is accessed on the browser, it now returns XML format and not plain text.

Hope this may help others in need. :)



来源:https://stackoverflow.com/questions/51923627/xml-sitemap-rendering-as-plain-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!