1
我想解析下面的XML,但我無法從SimpleXML中檢索任何孩子012tencerWhateverItem是第一個元素,它包含一些像whateverItem這樣的子元素:Properties,whateverItem:Test等。 應simplexml不返回孩子
$xmlDoc = new SimpleXMLElement($xml);
var_dump($xmlDoc->children());
返回兒童?
<whateverItem:item
xmlns:prop="http://whatever.de/core/01/properties/"
xmlns:srel="http://whatever.de/core/01/structural-relations/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:base="http://mybasewhatever:8080"
xlink:type="simple"
xlink:title="My Item Title"
xlink:href="/ir/item/whatever:1220"
last-modification-date="2011-07-07T12:52:55.415Z" >
<whateverItem:properties
xlink:type="simple"
xlink:title="Properties"
xlink:href="/ir/item/whatever:1220/properties">
<prop:creation-date>2011-07-04T15:17:50.855Z</prop:creation-date>
<srel:created-by xlink:type="simple" xlink:title="System Administrator User" xlink:href="/aa/user-account/whatever:exuser1" />
<prop:public-status>released</prop:public-status>
<prop:version xlink:type="simple" xlink:title="This Version" xlink:href="/ir/item/whatever:1220:4">
<version:number >4</version:number>
<version:date >2011-07-07T12:52:55.415Z</version:date>
<version:status >released</version:status>
<srel:modified-by xlink:type="simple" xlink:title="System Administrator User" xlink:href="/aa/user-account/whatever:exuser1" />
<version:comment >Status changed to released for Item whatever:1220.</version:comment>
</prop:version>
<prop:latest-version xlink:type="simple" xlink:title="Latest Version" xlink:href="/ir/item/whatever:1220:4">
<version:number >4</version:number>
<version:date >2011-07-07T12:52:55.415Z</version:date>
</prop:latest-version>
<prop:latest-release xlink:type="simple" xlink:title="Latest public version" xlink:href="/ir/item/whatever:1220:4">
<release:number >4</release:number>
<release:date >2011-07-07T12:52:55.415Z</release:date>
</prop:latest-release>
</whateverItem:properties>
...
<whateverItem:Test></whateverItem:Test>
</whateverItem:item>
我的輸出是對象(的SimpleXMLElement)#392(3){ [ 「@屬性」] =>數組 (1){ [ 「最後修改日期」] => 串(24),「2011 -07-07T12:52:55.415Z」 } [ 「屬性」] => 對象(的SimpleXMLElement)#376(0){ } [ 「測試」] => 對象(的SimpleXMLElement)#419(0 ){ } } – silex
奇怪的是,我只是獲得了@attributes而沒有其他東西! –
PHP版本5.3.1,阿帕奇/ 2.2.14,DOM/XML \t啓用, DOM/XML API版本\t 20031129, 的libxml版本2.7.3 \t, HTML支持\t啓用, XPath支持\t啓用, 的XPointer支持\t啓用, 模式支持\t啓用, RelaxNG支持\t啓用,libxml的加載版本\t 20703, libxml的流\t啓用,SimpleXML的支持\t啓用, 修訂\t $修訂:281953 $, 架構支持\t已啓用 – silex