I have a large XML file I am retrieving data from however I have several instances were the child elements are the same name and the XML reader stores the last one it come across:
<VehicleRemarketingBoat>
<MakeString>
Rodman Sportfisher
</MakeString>
</<VehicleRemarketingBoat>
<VehicleRemarketingEngine>
<MakeString>
Volvo
</MakeString>
</VehicleRemarketingEngine>
I would like to Detect the parent tag so I can then collect the data from the child tag.
THIS ISSUE IS SOLVED CODE UPDATED TO FIXED VERSION:
if($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'VehicleRemarketingBoat'){
$node = simplexml_import_dom($doc->importNode($xml->expand(), true));
$content['MakeString'] = $node->MakeString;
}
if($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'VehicleRemarketingEngine'){
$node = simplexml_import_dom($doc->importNode($xml->expand(), true));
$content['EngineMake'] = $node->MakeString;
$PreOwnedData[] = $content;
var_dump($PreOwnedData);
}