Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xml format in browsers when added xhtml

Tags:

I'm creating a Sitemap for a website and I noticed that the xml file loaded in a browser is displaying one long line of text instead of the usual pretty printed codes with line breaks.

My expected output would look something like this in these links example 1 and example 2. In case the links are broken, it should look like the image below.

Expected output

So I am creating a sitemap with alternate languages with the reference of this link from Google.

The xml becomes a one liner text when seen from the browser. Reference image below.

Actual Output

This is the xml code.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"  xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
    <loc>http://rfc.local/en/contact-us/contact-us-success-page</loc>
    <xhtml:link rel="alternate" hreflang="zh" href="http://rfc.local/hk/contact-us/contact-us-success-page" />
    <xhtml:link rel="alternate" hreflang="en" href="http://rfc.local/en/contact-us/contact-us-success-page" />
    <lastmod>2017-07-14</lastmod>
</url>
</urlset>

I've noticed that when I take out the xhtml tags, it then works fine. Is there a way to fix this? Any help would be much appreciated.

like image 608
qwert Avatar asked Jul 24 '17 06:07

qwert


1 Answers

I encountered the same problem but I finally found the solution. You must replace http by https in all the urls of the srcset tag :

<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"  xmlns:xhtml="https://www.w3.org/1999/xhtml">

It should work then.

Hope this helps

like image 115
KROMI Developers Avatar answered Sep 25 '22 11:09

KROMI Developers