[SimpleXML] extraire l'élément d'un tableau issu de simpleXML
Bonjour
Je butte sur un probléme
Je veux recupérer le contenu d'un element xml mais j'obtient un objet avec attribut + contenu. Comment séparer les deux
XML
Code:
1 2 3 4 5
|
<report>
<col id=1 width=10>Date</col>
<col id=2 width=20>Nom</col>
</report> |
pour extraire les infos
Code:
1 2 3 4 5 6
|
$xml=simplexml_load_file("file.xml");
$header=array();
foreach($xml->xpath('//col') as $col){
array_push($header,$col);
} |
Je recupère un tableau $header contenant : les attributs id, with et l'intitulé
Je sépare facilement les attributs par $col['id'] mais je n'atteint pas l'intitulé
Je voudrais stocker dans mon tableau $header que les intitulés
Merci