错误:自定义站点地图结构中的命名空间不正确



我想为我的网站创建自定义网站地图:https://adaway.info ,问题是当我写整个东西时,它给出了Incorrect Namespaces on a number of lines的错误。

谁能解释如何摆脱这种情况?

(PS:为了方便起见,我现在使用了yoast站点地图,但我真的在寻找一个自定义站点地图。

您必须非常小心,以确保架构和位置完全符合:

http://www.sitemaps.org/schemas/sitemap/0.9- 我曾经遇到过
http://www.sitemaps.org/schemas/sitemap/0.9
,它返回了您收到的相同错误。看看你是否能发现尾随的空格。

下面是一个使用 SimpleXML 的示例:

$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><urlset></urlset>');
$xml->addAttribute('xmlns','http://www.sitemaps.org/schemas/sitemap/0.9');
$xml->addAttribute('xmlns:xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
$xml->addAttribute('xmlns:xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd');

最新更新