添加xhtml时浏览器中的Xml格式

时间:2017-07-24 06:37:30

标签: xml format xhtml

我正在为网站创建Sitemap,我注意到浏览器中加载的xml文件显示的是一长行文本,而不是通常带有换行符的漂亮打印代码。

我的预期输出在这些链接example 1example 2中看起来像这样。如果链接断开,它应该如下图所示。

Expected output

因此,我创建了一个包含备用语言的站点地图,并引用了Google的link

从浏览器中看到xml成为单行文本。参考图片如下。

Actual Output

这是xml代码。

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

我注意到当我拿出xhtml标签时,它可以正常工作。有没有办法来解决这个问题?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,但终于找到了解决方案。您必须在srcset标记的所有网址中用http s 替换http:

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

那应该可以。

希望这会有所帮助