使用自定义属性创建有效的站点地图

时间:2014-02-18 11:57:23

标签: xml xsd sitemap

我正在网站上工作。我的网站有一个sitemap.xml文件。该文件可以看到here

如果向下滚动,您会看到包含一些自定义标记的url条目。这些标签以blog:为前缀可以看到博客命名空间的定义here

我已将我的站点地图提交给Google网站管理员工具。但是,我收到与博客命名空间关联的条目的警告。这些警告如下所示:

Warnings 

Invalid XML tag 

This tag was not recognized. Please fix it and resubmit. 

Parent tag: url
Tag: title 

Parent tag: url
Tag: description 

Parent tag: url
Tag: author 

我真的想在我的站点地图文件中包含一些自定义元素。同时,我想确保我的sitemap.xml不会生成任何警告。我的问题是,这可能吗?如果是这样,我做错了什么?谢谢!

3 个答案:

答案 0 :(得分:0)

“博客”架构的目标命名空间不应该与您在站点地图中指定的名称空间相同吗?

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
** xmlns:blog="http://www.ecofic.com" **     
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9     
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd     
http://www.ecofic.com/resources/root/blog/1.0 
http://www.ecofic.com/resources/root/blog.xml">

答案 1 :(得分:0)

如下定义命名空间属性?

<html xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:blog="http://www.google.com/2005/gml/b">

答案 2 :(得分:0)

我在站点地图中为属性使用自定义命名空间: http://pics.jonathancross.com/sitemap.xml

他们似乎工作正常。

以下属性是jcd命名空间的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<urlset
    xmlns:jcd="http://pics.jonathancross.com"
    jcd:date="2015-09-16"
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url jcd:imgs="0" jcd:dsize="1.3G">
    <loc>http://pics.jonathancross.com/</loc>
    <lastmod>2015-09-16</lastmod>
    <priority>1.0</priority>
  </url>
  ...

我还使用这样的自定义desc元素:

<jcd:desc>Description of page here</jcd:desc>

该元素会导致Google网站站长工具中出现错误,但网站站长工具似乎仍然会解析其理解的站点地图数据。

动机:

将自定义数据添加到我的站点地图意味着它可以用作我的站点的中央数据库。我还使用xslt将相同的数据呈现为一个结构化的链接表,供人们浏览网站。

相关问题