Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Sitemap rendering as plain text

Tags:

xml

sitemap

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.

like image 558
Weisen Avatar asked Aug 20 '18 02:08

Weisen


1 Answers

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. :)

like image 134
Weisen Avatar answered Oct 30 '22 18:10

Weisen