I'm having a seemingly impossible time getting my head around simple XML and soap. I've read in a file to simple xml, and this is the result to show it's read in properly:
echo $garages->asXML();
// result
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetListOfFittingCentresResponse xmlns="http://TyreMen.com/UkTyreNetwork/">
<GetListOfFittingCentresResult xmlns:a="http://TyreMen.com/UkTyreNetwork/Response/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Method>GetListOfFittingCentres</a:Method>
<a:Result>
<a:Code>0</a:Code>
<a:Description>Call completed successfully</a:Description>
</a:Result>
<a:FittingCentres xmlns:b="http://TyreMen.com/UkTyreNetwork/DataTypes/">
<b:FittingCentre>
<b:Address1>Tyremen</b:Address1>
<b:Address2>Witty Street</b:Address2>
<b:Address3>Hull</b:Address3>
<b:Address4/>
<b:BranchName>Witty Street</b:BranchName>
<b:GEOLocation>
<b:Latitude>53.732342619574524</b:Latitude>
<b:Longitude>-0.3738183264892996</b:Longitude>
</b:GEOLocation>
</b:FittingCentre>
</a:FittingCentres>
</GetListOfFittingCentresResult>
</GetListOfFittingCentresResponse>
</s:Body>
</s:Envelope>
But I can't for the life of me work out how to reference any of that data. I've tried both these:
$t = $garages->children('s', TRUE)->Body->GetListOfFittingCentresResponse->GetListOfFittingCentresResult->children('a', TRUE)->FittingCentres->children('b', TRUE)->FittingCentre;
foreach ($t as $garage) {
echo $garage->Address1."<br />";
}
and
echo $garages->GetListOfFittingCentresResponse->GetListOfFittingCentresResult->FittingCentres->FittingCentre[0]->Address1;
Both just throw faults, and I'm afraid I'm out of ideas.
Please can someone suggest where I'm being an idiot. Thanks :)