I’m currently using file_get_contents to get an xml.
It work well and when I display the xml with the correct MIME type header(‘Content-type: text/xml’) I obtain something like this :
<?xml version="1.0" encoding="iso-8859-1" ?>
<tarification compagnie="banane" cle="laclef">
<gamme reference="equilibre-sante">
<tarif formule="f100">Xx.xx</tarif>
<tarif formule="f200">Xx.xx</tarif>
</gamme>
</tarification>
To use it as an object I use simplexml_load_string but when I print_r the returned object I didn’t see the formule attribute I just see something like this :
SimpleXMLElement Object
(
[@attributes] => Array
(
[compagnie] => banane
[cle] => laclef
)
[gamme] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[reference] => equilibre-sante
)
[tarif] => Array
(
[0] => Xx.xx
[1] => Xx.xx
)
)
)
)
I want to get formule attributes, I have already tested to do this by following this tutorial without success.
You need to use the
SimpleXMLElement::attributesas:See it