I have an XML string obtained as response of SoapClient request (I have also tried with cURL)
I then use:
$xml = simplexml_load_string($result);
I am able to obtain the attributes of a node inside $xml by the node index (Lets say I want to access vehicle node with index 100:
dump($xml->vehicle[100]->attributes());
Or I can access a particular attribute by its name:
dump($xml->vehicle[100]['key']):
When I try to do the same inside a foreach it doesn't work
foreach($xml->vehicle as $car) {
dump($car->attributes());
}
I have also tried the following without success
$vehicles = array();
foreach($xml->vehicle as $index => $car) {
$vehicles[$index] = array($car->attributes());
}
dump($vehicles);
I am currently just trying to dump the attributes of each node but my goal is to later create an entry in a Vehicles database and each attribute is a column, the amount of rows depends on the response of SoapClient or cURL
How can I access the attributes of each node inside a foreach?
Thank you in advance for the help
EDIT
I get HTTP error 500 but I have already increased the default socket timeout to 6000 (Just in case haha) but if I remove the foreach then the code completes the execution in around 1 min