9

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.

Weisen
  • 522
  • 3
  • 14
  • What browser are you using? Chrome won't render xml in any pretty format for you. Try firefox or internet explorer – dpix Aug 20 '18 at 03:01
  • @dpix I tried viewing it using different browsers (IE Edge, Chrome, FF and IE 11) but it's still rendering the same plain text format. But if I view the page source, it does show as XML format. – Weisen Aug 20 '18 at 03:05

1 Answers1

16

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

Weisen
  • 522
  • 3
  • 14
  • 13
    This works to see the correct XML format on the browser, but Google doesn't recognize the sitemap, I get this error when I submit the sitemap to Google search console: "Your Sitemap or Sitemap index file doesn't properly declare the namespace. Line: 2" – Maria Vilaró Dec 07 '18 at 09:48