gpt4 book ai didi

php - DOMDocument::loadXML():预期开始标记: "<"

转载 作者:可可西里 更新时间:2023-11-01 13:41:06 24 4
gpt4 key购买 nike

我又遇到了一个问题,目前 XML 对我来说不是很好...为什么我会收到此错误消息,我该如何解决?

我收到每个 XML 文件的错误消息!

错误信息:

PHP Warning:  DOMDocument::loadXML(): Start tag expected, '<' not found in Entity, line: 1 in C:\Users\Jan\PhpstormProjects\censored\Matcher.php on line 36
Warning: DOMDocument::loadXML(): Start tag expected, '<' not found in Entity, line: 1 in C:\Users\Jan\PhpstormProjects\censored\Matcher.php on line 36

代码:

function loadTitlesIntoArray($tagName, $path){

$dom = new DOMDocument('1.0', 'utf-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($path);

$titels = array();
$marker = $dom->getElementsByTagName($tagName);

for ($i = $marker->length - 1; $i >= 0; $i--) {
$new = $marker->item($i)->textContent;
array_push($titels, $new);
}

print_r($titels);
}

loadTitlesIntoArray('标题', $kinguinPath);

XML:

<?xml version="1.0" encoding="UTF-8"?>
<rss>
<channel xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<title><![CDATA[google_EUR_english_1]]></title>
<link><![CDATA[http://cdn.kinguin.net/media/feedexport/google_EUR_english_1.xml]]></link>
<item>
<title><![CDATA[Anno 2070 Uplay CD Key]]></title>
<link><![CDATA[http://www.kinguin.net/category/4/anno-2070/?nosalesbooster=1&country_store=1&currency=EUR]]></link>
<g:price><![CDATA[3.27 EUR]]></g:price>
<g:image_link><![CDATA[http://cdn.kinguin.net/media/catalog/category/anno_8.jpg]]></g:image_link>
</item>
<item>
<title><![CDATA[Anno 2070: Deep Ocean DLC Uplay CD Key]]></title>
<link><![CDATA[http://www.kinguin.net/category/5/anno-2070-deep-ocean-expansion-pack-dlc/?nosalesbooster=1&country_store=1&currency=EUR]]></link>
<g:price><![CDATA[4.74 EUR]]></g:price>
<g:image_link><![CDATA[http://cdn.kinguin.net/media/catalog/category/anno-2070-deep-ocean-releasing-this-spring-1089268_1.jpg]]></g:image_link>
</item>
</channel>
</rss>

您好,谢谢!

最佳答案

loadXML 期待一个 string of XML但你正试图给它一个文件路径。尝试 load .或者,您可以将 XML 文件加载到字符串中,然后调用 loadXML。

关于php - DOMDocument::loadXML():预期开始标记: "<",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41452807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com