Bonjour,
Je suis novice en php, et je ne comprends pas encore tout.
Je voudrais afficher "ok, je ne fait plus de bruit" quand $world = "silence"
1 2 3 4 5
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<contacts>
<contact><In>silence</In><Out>ok, je ne fait plus de bruit</Out></contact>
<contact><In>écoute</In><Out>je suis toutes ouies</Out></contact>
</contacts> |
Le programme plante a la linge :
echo $Out->firstChild->nodeValue . "<br />";
Donc, que dois je faire pour corriger cette erreur.
Comment déclaré $Out pour que ça fonctionne en gardant ma fonction openXML ?
Merci beaucoup.
@+
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <?php
function openXML($File,$world)
{
$dom = new DomDocument;
$dom->load($File);
$contact = $dom->getElementsByTagName('contact')->item(0);
$listeContact = $contact->getElementsByTagName('In');
foreach($listeContact as $In)
{
if($world==$In->firstChild->nodeValue)
{
echo $Out->firstChild->nodeValue . "<br />"; // Bup ICI!!!!
}
}
}
?>
<?php
openXML("toto1.xml","silence");
?> |
Partager