SimpleXMLElement array only returns one element

1.1k views Asked by At

I have the following Simple XML structure var_dump'ed:

var_dump($data) results in:

object(SimpleXMLElement)[269]
  public 'columns' => 
    object(SimpleXMLElement)[283]
      public 'column' => 
        array (size=11)
          0 => 
            object(SimpleXMLElement)[274]
              public '@attributes' => 
                array (size=2)
                  'name' => string 'test' (length=10)
                  'display' => string 'test ID' (length=11)
          1 => 
            object(SimpleXMLElement)[273]
              public '@attributes' => 
                array (size=2)
                  'name' => string 'blah' (length=8)
                  'display' => string 'blah' (length=8)
          ....
          ....
          ....
  public 'row' => 
    array (size=6)
      0 => 
        object(SimpleXMLElement)[270]
          public '@attributes' => 
            array (size=11)
              'test' => string '3445543' (length=8)
              'blah' => string 'Some Text' (length=13)
      1 => 
        object(SimpleXMLElement)[279]
          public '@attributes' => 
            array (size=11)
              'test' => string '3445543' (length=8)
              'blah' => string 'Some Text' (length=13)
      2 => 
        object(SimpleXMLElement)[278]
          ....
          ....
          ....

I shortened the output as you can see just to save room. But the row array contains 6 elements as you can see.

Now if I do this:

echo count($data->row); I get 6 as expected.

If I do this:

var_dump($data->row); I get this...

object(SimpleXMLElement)[270]
  public '@attributes' => 
    array (size=11)
      'test' => string '3445543' (length=8)
      'blah' => string 'Some Text' (length=13)

It prints out one element. No array.

Why would the count of the array return the right value but fetching the array only gets the first element of the array? How do I get all of the elements?

0

There are 0 answers