【发布时间】:2015-10-23 02:46:14
【问题描述】:
我有以下 XML 结构:
<parent>
<child foo="bar1" foo2="bar2"/>
<child foo="bar3" foo2="bar4"/>
</parent>
在 PHP 中:
foreach ($xml->parent->child as $item)
返回“为 foreach() 提供的参数无效”
我可以用 SimpleXML 遍历那些孩子吗? 是的,在 /> 附近的行尾没有空格 .. 有问题吗?我只是得到数据,我必须解析它....
【问题讨论】:
-
那是你的完整 xml 吗?你能提供你实例化 $xml 对象的代码吗?