0

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

谁能解释如何摆脱这个?

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

4

1 回答 1

0

您必须非常小心,以确保架构和位置与此完全相同:

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');
于 2019-03-11T22:59:05.640 回答