0
我不斷收到以下錯誤,當我添加的xmlns到我的XML與DOM文檔PHP DOM文檔寫作網站地圖問題 - 未捕獲的異常「拋出:DOMException」
書面致命錯誤:未捕獲的異常「拋出:DOMException」與消息「無效字符錯誤」 ...
$xml = new DOMDocument("1.0", "UTF-8");
$xml_urlset = $xml->createElement('urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"');
$xml_url = $xml->createElement("url","this text");
$xml_urlset->appendChild($xml_url);
$xml->appendChild($xml_urlset);
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->save("test.xml");
而且,即使我有formatOutput =真我仍然得到的一切寫出來作爲一個長線:
<urlset>xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"<url>this text</url></urlset>
我嘗試荷蘭國際集團設置的東西所以這可能是outputed的網址設定
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
感謝您的幫助,您可以給我。