user1721449 user1721449 - 4 months ago 7x
jQuery Question

Parsing XML file after converting to json with PHP

I have an XML url that I need to parse and paginate on a jquery ajax request. I'm not too much experience in PHP and I'm trying to figure out how I can get the values of each item?

My code:

$xmlFile = simplexml_load_file($xmlURL);
$json = json_encode($xmlFile);
$array = json_decode($json,TRUE);

echo "<pre>";
echo "</pre>";

The output (trying to traverse through this):

[item] => Array
[0] => Array
[title] => English Matters Book Group for English Language Learners
[date] => Wednesday, June 15, 2016
[time] => 10:00 AM


A standard foreach loop would suffice:

foreach ($array['item'] as $item) {
    echo $item['title'] . '<br />';