【发布时间】:2014-03-21 17:35:34
【问题描述】:
我正在编辑 XML 解析器,但我遇到了问题;该网站有一个 & ,我无法解决它。
我试过了,没用:
$text=preg_replace('/&(?!#?[a-z0-9]+;)/', '&', $text);
这是行:
$dom = DOMDocument::load('https://www.bet-at-home.com/en/feed/sport?sportID=5&username=yyy&password=xxx');
我不知道如何使用 CDATA,这似乎是唯一的解决方案。
这是错误:
Warning: DOMDocument::load() [domdocument.load]: xmlParseEntityRef: no name in https://www.bet-at-home.com/en/feed/sport?sportID=5&username=yyy&password=xxx, line: 21 in /home/public_html/bet/cronload.php on line 13
非常感谢您的帮助!
这是解决方案:
$content = file_get_contents('https://www.bet-at-home.com/en/feed/sport?sportID=1&username=xxx&password=yyy');
$dom = DOMDocument::loadXML($content);
【问题讨论】:
标签: php xml xml-parsing cdata