Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何使用w3c sitemap.xsd验证w3c sitemap&;谷歌网站地图?_Xml_Xsd_Sitemap_W3c - Fatal编程技术网

Xml 如何使用w3c sitemap.xsd验证w3c sitemap&;谷歌网站地图?

Xml 如何使用w3c sitemap.xsd验证w3c sitemap&;谷歌网站地图?,xml,xsd,sitemap,w3c,Xml,Xsd,Sitemap,W3c,w3c sitemap.xsd: 看起来是这样的: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" elementFormDefault="qualified"> <?xml versi

w3c sitemap.xsd:
看起来是这样的:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" elementFormDefault="qualified">
<?xml version="1.0" encoding="UTF-8"?>                                                                                                                                                                                                       
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://t.qq.com/p/t/42509089158929/</loc></url>
</urlset>
我认为,问题在于google-sitemap.xml和sitemap.xsd中的名称空间不同。 如何使用sitemap.xsd验证这两个站点地图文件


谢谢

如果google sitemap实例文档中没有对sitemaps.org sitemap模式的引用,那么我看不出您应该如何验证它,甚至不知道您为什么要验证它


通过在文件顶部包含名称空间,google sitemap实例清楚地表明它是google.com sitemap模式的实例,而不是sitemaps.org sitemap模式

每个文件的主体完全相同。站点地图文件包括。。。对于这样的标记,我想通过一个xsd(模式)文件来验证这些文件,但我没有做到这一点。如果我删除google sitemap文件中的xmlns=“”,验证将通过。无论文件的主体是什么,namespace属性都定义了xml中类型的定义位置。如果您想要验证一个文件,该文件声明它的类型是在schemaA中定义的,但是使用schemaB,它将不起作用。哦,太糟糕了。我想验证这些xml,忽略它们的名称空间声明,你知道吗?我使用xerces-c库。
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.9"> 
<url>
<loc>http://blog.ifeng.com/article/11487489.html</loc>
<lastmod>2011-05-23T09:33:01+08:00</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</urlset>
$ xmllint --schema sitemap.xsd sitemap_google.xml  --noout 
sitemap_google.xml:2: element urlset: Schemas validity error : Element '{http://www.google.com/schemas/sitemap/0.9}urlset': No matching global declaration available for the validation root.
sitemap_google.xml fails to validate