我有以下 SimpleXML 代码。当我打印输出时,它似乎总是跳过第一个元素。因此,在下面的示例中,它跳过了品牌元素并直接进入网站。无论我有多少个子级别,它总是跳过第一个。
这是正常的吗?我怎样才能解决这个问题?
$xml = '
<brands>
<websites>
</websites>
</brands>
';
$xml = simplexml_load_string($xml);
echo "<pre>";
print_r($xml);
echo "</pre>";
示例输出:
SimpleXMLElement Object
(
[websites] => SimpleXMLElement Object
(
[0] =>
)
)
只需使用另一个元素包装它:
<root>
<brands>
<websites>
</websites>
</brands>
</root>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句