Home >Backend Development >PHP Tutorial > SimpleXMLElement 有关问题

SimpleXMLElement 有关问题

WBOY
WBOYOriginal
2016-06-13 12:54:41963browse

SimpleXMLElement 问题
object(SimpleXMLElement)[7]
  public 'trades' => 
    object(SimpleXMLElement)[8]
      public '@attributes' => 
        array (size=1)
          'list' => string 'true' (length=4)
      public 'trade' => 
        array (size=3)
          0 => 
            object(SimpleXMLElement)[9]
              ...
          1 => 
            object(SimpleXMLElement)[10]

将 $xml 打印出来是这样,如何获取 数组形式的trade

$xml->trades->trade 获取的总是数组第一个对象
和$xml->trades->trade[0] 结果一样

求高手,如果最简单一次获取到 trade 数组中内容


------解决方案--------------------
print_r($xml->trades->trade); //是什么结果
------解决方案--------------------
可以使用数组的方式来操作,
比如说$xml->trades->trade[0],
但不能把他当成数组。

默认取的是第一项。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn