Se connecter avec
S'enregistrer | Connectez-vous

Gestion de fichiers xml par php

Dernière réponse : dans Programmation

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 :


Citation :
<?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 :


Citation :
<?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 :



<
Citation :
!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 :
Citation :
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.

Autres pages sur : gestion fichiers xml php

Lassé par la pub ? Créez un compte

Citation :
bizarre...

l'erreur ne correspond pas au bout de code donné

tu es sur de ta version de pho ?


De ma version php je suppose? Php info m'indique 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



Citation :
Heuuh, sinon, c'est la balise [code] (bouton <image>) qu'il faut pour insérer du code, pas quote ;) ..


C'est noté!
Lassé par la pub ? Créez un compte