I have retrieved the xml file successfully and printed it out as an array but what I want to do is loop through the file and perform some operations on each record. I tried a foreach loop with ->children but I just can;t seem to print anything
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://www.test.co.uk/test.xml',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_ENCODING => 'UTF-8'
));
$data = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
//die('<pre>' . print_r($xml, TRUE) . '</pre>');
echo $xml->row[0]['user'];
die();
Data looks like this in the array:
<pre>SimpleXMLElement Object
(
[row] => Array
(
[0] => SimpleXMLElement Object
(
[user] => aaa
[enabled] => 1
[email_address] => aaa@gmail.com
[OrderDate] => 2018-08-01 10:25:04
[products_id] => 381
[NewOrder] => 0
[ResendKeys] => 0
[LastUpdate] => 2018-12-19 02:36:26
)
[1] => SimpleXMLElement Object
(
[user] => bbb
[enabled] => 1
[email_address] => bbb@gmail.com
[OrderDate] => 2018-12-19 02:50:27
[products_id] => 380
[NewOrder] => 0
[ResendKeys] => 1
[LastUpdate] => 2018-12-19 02:50:27
)