It’s my xml file:
<?xml version="1.0" encoding="utf-8" ?>
<documentElement>
<rows>
<row>
<column>1</column>
<column>David</column>
<column>Johnson</column>
</row>
<row>
<column>2</column>
<column>Jack</column>
<column>Nixon</column>
</row>
</rows>
</documentElement>
I want to loop over rows and add them to an array. I passed it to simplexml and then loop through these objects, but couldn’t do it:
$xml->rows
$xml->rows->row
$xml->row
$xml->column
What should I do?
Thanks.
This is actually one of the more basic examples:
Which will give you the following output:
You can find an online-demo here: http://codepad.org/CYyQhvnM
You should actually take a look at the simple exmamples section in the manual, it has some very insightful examples that are explained more in depth than mine here:
I hope the answer is helpful anyway. Related questions are: