array map ne fonctionne pas pour parser un fichier xml
Bonjour à tous,
Je m'excuse d'avance car je suis un débutant, et je bloque sur un soucis depuis des heures
Voici mon fichier xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <hash>
<languages type="array">
<language>es</language>
</languages>
<profile-pic>https...</profile-pic>
<videos type="array"/>
<photos type="array">
<photo>
<thumb>https...</thumb>
<full>https...</full>
</photo>
<photo>
<thumb>https...</thumb>
<full>https...</full>
</photo>
<photo>
<thumb>https...</thumb>
<full>https...</full>
</photo>
</photos> |
J'arrive à récupérer les languages comme ceci :
Code:
1 2 3 4 5 6 7 8
| $entry = $xpath->evaluate('/hash');
$languages = array_map(
function(\DOMElement $node) {
return $node->textContent;
},
iterator_to_array($xpath->evaluate('languages/language', $entry))
);
echo implode(',', $languages); |
Par contre pour récupérer les photos impossible !
Code:
1 2 3 4 5 6 7 8
| $entry = $xpath->evaluate('/hash');
$photos = array_map(
function(\DOMElement $node) {
return $node->textContent;
},
iterator_to_array($xpath->evaluate('photos/photo/thumb', $entry))
);
$images = implode(',', $photos); |
j'ai carrément une erreur 500 !
Merci d'avance si un fin connaisseur pourrait m'éclairer :)
bonne soirée