这个sitemap.xml文件无效?

时间:2013-09-17 01:51:43

标签: xml seo sitemap

我在我的网站上添加了一个sitemap.xml文件(请参阅Why is my sitemap file considered empty?),谷歌表示xml无效:

Warnings
Invalid XML: too many tags
Too many tags describing this tag. Please fix it and resubmit.
Issues count: 48
Examples: 
Line 16: Parent tag: url
Tag: loc

Line 17:
Parent tag: url
Tag: lastmod

Line 18:
Sep 16, 2013
Parent tag: url
Tag: changefreq

这是sitemap.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>http://www.awardwinnersonly.com</loc>
    <lastmod>2013-09-16</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>http://www.awardwinnersonly.com/getHugos.cshtml</loc>
    <lastmod>2013-09-16</lastmod>
    <changefreq>weekly</changefreq>
    <priority>.7</priority>
    <loc>http://www.awardwinnersonly.com/Content/pulitzers2.json</loc>
    <lastmod>2013-09-16</lastmod>
    <changefreq>monthly</changefreq>
    <priority>.7</priority>
    <loc>http://www.awardwinnersonly.com/Content/nba.json</loc>
    <lastmod>2013-09-16</lastmod>
    <changefreq>monthly"</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/NBCCJr.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/noba.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/grammies.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/indies.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/ama.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/cma.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/oscars.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/sundance.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/cannes.json</loc>
      <lastmod>20 13-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
      <loc>http://www.awardwinnersonly.com/Content/goldenglobes.json</loc>
      <lastmod>2013-09-16</lastmod>
      <changefreq>monthly</changefreq>
      <priority>.7</priority>
    </url>
</urlset>

2 个答案:

答案 0 :(得分:3)

您错过了大多数商家信息中的开始和结束<url></url>标签。

答案 1 :(得分:1)

有几种工具可以自动生成sitemap.xml,例如Kohana module。这样可以确保我们避免手动或由于上传问题而导致无效的xml文件。

以下示例代码显示如何在服务器上生成sitemap.xml:

// Sitemap instance.
$sitemap = new Sitemap;

//this is assume you put an array of all url in a cache named 'sitemap'
foreach($cache->get('sitemap') as $loc)
{
    // New basic sitemap.
    $url = new Sitemap_URL;

    // Set arguments.
    $url->set_loc($loc)
        ->set_last_mod(1276800492)
        ->set_change_frequency('daily')
        ->set_priority(1);

    // Add it to sitemap.
    $sitemap->add($url);
}

// Render the output.
$response = $sitemap->render();

// Cache the output for 24 hours.
$cache->set('sitemap', $response, 86400);

// Output the sitemap.
echo $response;