Roumen Damianoff laravel-sitemap上的XML格式错误

时间:2015-07-08 14:47:42

标签: xml laravel laravel-4

我正在尝试使用laravel-sitemap 2.4.16由Roumen Damianoff为laravel 4.2网站开发xml站点地图,但渲染的xml无效,并且在大多数浏览器中都没有正确显示。

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9  http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>http://localhost/vinas/public</loc>
    <xhtml:link rel="alternate" hreflang="es" href="http://localhost/vinas/public/es/inicio" />
    <xhtml:link rel="alternate" hreflang="en" href="http://localhost/vinas/public/en/home" />
    <xhtml:link rel="alternate" hreflang="fr" href="http://localhost/vinas/public/fr/home" />
    <xhtml:link rel="alternate" hreflang="pt" href="http://localhost/vinas/public/pt/home" />
    <xhtml:link rel="alternate" hreflang="ca" href="http://localhost/vinas/public/ca/inici" />
    <priority>1.0</priority>
    <lastmod>2015-07-08T11:03:08+02:00</lastmod>
    <changefreq>weekly</changefreq>
</url>
</urlset>

如果我尝试将翻译添加到站点地图,就会发生这种情况,如果我不这样做,一切正常。 xml验证错误如下...

  

匹配的通配符是严格的,但是找不到声明   元素&#39; xhtml:链接&#39;。

如何修复此xml?或者......一切正常,即使xml在某些浏览器上无法正常呈现,爬虫也会很好地利用它?

1 个答案:

答案 0 :(得分:0)

如下所示更改订单

  <url>
    <loc>http://localhost/vinas/public</loc>
    <lastmod>2015-07-08T11:03:08+02:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>

    <xhtml:link rel="alternate" hreflang="es" href="http://localhost/vinas/public/es/inicio" />
    <xhtml:link rel="alternate" hreflang="en" href="http://localhost/vinas/public/en/home" />
    <xhtml:link rel="alternate" hreflang="fr" href="http://localhost/vinas/public/fr/home" />
    <xhtml:link rel="alternate" hreflang="pt" href="http://localhost/vinas/public/pt/home" />
    <xhtml:link rel="alternate" hreflang="ca" href="http://localhost/vinas/public/ca/inici" />
  </url>