Gestion de fichiers xml par php
Bonjour à tous,
J'essaye d'afficher le nom de la racine xml, puis l'ensemble des titres du fichier, par une fonction php.
Voici mon php :
Code:
1 2 3 4 5 6 7 8
| <?php
$dom= new domDocument('1.0', 'iso-8859-1');
$dom->load('essai.xml');
//$dom->validate();
$racine=$dom->documentElemnt;
echo $racine->nodeName;
?> |
Voici mon essai.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE livre SYSTEM "livre.dtd">
<livre titre="Annabac 2007">
<Chapitre titre="Maths">
<texte> Maths Maths Maths Maths Maths Maths Maths Maths Maths Maths Maths Maths </texte>
</Chapitre>
<Chapitre titre="Physiques">
<texte> Physiques Physiques Physiques Physiques Physiques Physiques Physiques Physiques Physiques Physiques Physiques Physiques </texte>
</Chapitre>
<Chapitre titre="SVT">
<texte> SVT SVT SVT SVT SVT SVT SVT SVT SVT </texte>
</Chapitre>
</livre> |
Et voici mon DTD :
Code:
1 2 3 4 5 6 7
| <!ELEMENT Chapitre ( texte ) >
<!ATTLIST Chapitre titre NMTOKEN #REQUIRED >
<!ELEMENT livre ( Chapitre+ ) >
<!ATTLIST livre titre CDATA #REQUIRED >
<!ELEMENT texte ( #PCDATA ) > |
Je l'ai fait en cours, cela marche très bien (nous sommes sous linux)
Mais dès que je teste chez moi (c'est à dire : PC windows XP, seveur Free.)
J'ai cette erreur :
Code:
1 2 3
| Warning: domdocument() expects at least 1 parameter, 0 given in /mnt/124/free.fr/c/d/seb1395/xmltest/index.php on line 2
Fatal error: Call to undefined function: load() in /mnt/124/free.fr/c/d/seb1395/xmltest/index.php on line 3 |
Merci pour votre aide !!!
Je suis sur que c'est encore une histoire de " " ".
Bonne fin de soirée.