simpleXML返回空元素

问题描述 投票:0回答:2

阅读XML Feed时遇到问题XML文件样本:

<f:feed xmlns:f="http://www.bbgo.de/feedxml/feed" xmlns:a="http://www.bbgo.de/feedxml/article" xmlns="http://www.w3.org/1999/xhtml" f:customer="blub" f:name="dax-tecdax">
<f:title>Analysen: DAX, TecDAX</f:title>
<f:date>2010-09-22T20:46:29+02:00</f:date>
<f:url>http://www.bbgo.de/export/feed/stock-channel/dax-tecdax</f:url>
<f:articles>
<a:article a:id="2310446" a:status="published" a:payed-content="false" xml:lang="de-DE">
<a:title>Kabel Deutschland mit Verkaufsempfehlung</a:title>...

一个简单的测试,如:

$feed = new SimpleXMLElement($xml);
print_r($feed);

产生

SimpleXMLElement Object ( )

如果我尝试

echo $xml;

以上示例正确地回显。

为什么不构建$ feed数组?如何访问<a:article>中的所有<f:articles>

php xml rss simplexml feed
2个回答
0
投票

如何访问<a:article>中的所有<f:articles>


0
投票

我有类似的问题,结果证明该问题与CDATA有关。

© www.soinside.com 2019 - 2024. All rights reserved.