Voici le script qui me pose problème. Ma seconde boucle foreach ne fonctionne pas comme je veux, j'espère que vous trouverez la solution à mon problème :
$xml = simplexml_load_file('kanjidic2.xml');
echo 'Document XML DTD <i>kanjidic2.xml</i> chargé avec succès.<hr />';
$i = 0;
echo '<b>Code Point insérés :</b><br />';
$i = 0;
foreach ($xml->character as $char)
{
$i++;
echo $char->literal .' > ';
foreach($char->codepoint->cp_value->attributes() as $a => $b)
{
echo $a .'_'. $b .'['. $char->codepoint->cp_value .'] ';
}
echo '<br />';
if ($i == 10) break;
}
echo '<hr />';
Voici un extrait de mon document XML à parser :
Code : Tout sélectionner
<character>
<literal>test</literal>
<codepoint>
<cp_value cp_type="ucs">4e9c</cp_value>
<cp_value cp_type="jis208">16-01</cp_value>
</codepoint>
</character>Voici le résultat affiché au final :
Code Point insérés :
亜 > cp_type_ucs[4e9c]
唖 > cp_type_ucs[5516]
娃 > cp_type_ucs[5a03]
阿 > cp_type_ucs[963f]
哀 > cp_type_ucs[54c0]
愛 > cp_type_ucs[611b]
挨 > cp_type_ucs[6328]
姶 > cp_type_ucs[59f6]
逢 > cp_type_ucs[9022]
葵 > cp_type_ucs[8475]
J'aimerais que ça affiche pour CHAQUE entrée, toutes les informations cp_type & cp_value, à savoir pour le premier enregistrement :
亜 > cp_type_ucs[4e9c], cp_type_jis208[16-01]
Quelques liens qui devraient vous aider :
http://fr.php.net/manual/fr/ref.simplexml.php
La page qui affiche le résultat du script posté ici :
http://www.grossebertha.net/simplexml.php
Merci beaucoup de m'accorder un peu de temps ! Je reste disponible si vous avez besoin d'éléments supplémentaires.