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 :
- <?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 :
- <?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 :
- <!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 :
- 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
|
De plus voici ce que j'ai avec phpinfo :
Code :
- PHP Version 4.4.3-dev
- domxml
- DOM/XML enabled
- DOM/XML API Version 20020815
- libxml Version 20616
- HTML Support enabled
- XPath Support enabled
- XPointer Support enabled
- DOM/XSLT enabled
- libxslt Version 1.1.12
- libxslt compiled against libxml Version 2.6.16
|
Merci pour votre aide !!!
Je suis sur que c'est encore une histoire de " " ".
Bonne fin de soirée.