Php simplexml未返回子项

Php simplexml未返回子项,php,xml,parsing,simplexml,Php,Xml,Parsing,Simplexml,我试图解析以下XML,但无法从SimpleXML中检索任何子项 这个 WhateverItem是第一个元素,它包含两个子元素,如WhateverItem:Properties、WhateverItem:Test等。 应该 $xmlDoc = new SimpleXMLElement($xml); var_dump($xmlDoc->children()); 还孩子 <whateverItem:item xmlns:prop="http://whatever.de/core/01/

我试图解析以下XML,但无法从SimpleXML中检索任何子项 这个 WhateverItem是第一个元素,它包含两个子元素,如WhateverItem:Properties、WhateverItem:Test等。 应该

$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>

2011-07-04T15:17:50.855Z
释放
4.
2011-07-07T12:52:55.415Z
释放
项目状态更改为已发布:1220。
4.
2011-07-07T12:52:55.415Z
4.
2011-07-07T12:52:55.415Z
...

您是否在实际的XML输入中声明了“whateverItem”命名空间?首先,尝试通过xmllint(大多数Linux发行版中的命令行实用程序)运行您的输入,看看它是否发现任何问题。

您是否在实际的XML输入中声明了“whateverItem”名称空间?首先,尝试通过xmllint(大多数Linux发行版中的命令行实用程序)运行您的输入,看看它是否发现了任何问题。

我的输出是object(SimpleXMLElement)#392(3){[@attributes”=>array(1){[“last modification date”]=>string(24)“2011-07-07T12:52:55.415Z”}[“properties”=>object(SimpleXMLElement)356(0){}[“Test”]=>对象(simplexmlement)#419(0){}真奇怪,我只得到了@attributes,别的什么都没有!PHP版本5.3.1、Apache/2.2.14、启用DOM/XML、启用DOM/XML API版本20031129、启用libxml版本2.7.3、启用HTML支持、启用XPath支持、启用XPointer支持、启用模式支持、启用RelaxNG支持、启用libxml加载版本20703、启用libxml流、简单启用xml支持,修订版$Revision:281953$,启用模式支持谢谢你。我想应该还有另一个问题。我使用的xml代码有点大,我没有放所有的“children”在上面的代码中。使用上面的代码,我能够检索到相同的结果。谢谢!正在寻找调试错误的方法,因为libxml_get_last_error()没有提供任何信息。我的输出是object(SimpleXMLElement)#392(3){[“@attributes”]=>array(1){[“last modification date”]=>string(24)“2011-07-07T12:52:55.415Z”}[“属性”]=>object(simplexmlement){}[“测试”]=>object(simplexmlement){}419(0){}”真奇怪,我只得到了@attributes,别的什么都没有!PHP版本5.3.1、Apache/2.2.14、启用DOM/XML、启用DOM/XML API版本20031129、启用libxml版本2.7.3、启用HTML支持、启用XPath支持、启用XPointer支持、启用模式支持、启用RelaxNG支持、启用libxml加载版本20703、启用libxml流、简单启用了xml支持,修订版$Revision:281953$,启用了模式支持谢谢你Silex。我想应该还有另一个问题。我使用的xml代码有点大,我没有把所有的“在上面的代码中。使用上面的代码,我能够检索到相同的结果。谢谢!正在寻找调试错误的方法,因为libxml_get_last_error()没有提供任何信息