1

我向我的站点添加了一个 sitemap.xml 文件(请参阅为什么我的站点地图文件被认为是空的?),谷歌说 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>
4

2 回答 2

3

您的<url></url>大多数列表都缺少开始和结束标签。

于 2013-09-17T02:06:32.457 回答
1

有几个工具可以自动生成 sitemap.xml,例如这个Kohana 模块。这将确保我们避免手动生成无效的 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;
于 2015-04-06T07:22:29.390 回答