0
Essayer de créer un système de news rapide et corrompu.Afficher une entrée XML basée sur l'ID
Avoir un fichier XML de base.
<?xml version="1.0" encoding="ISO-8859-1"?>
<articles>
<article id="1">
<title>Article title 001</title>
<short>Short text</short>
<long>Long text</long>
</article>
<article id="2">
<title>Article title 002</title>
<short>Short text</short>
<long>Long text</long>
</article>
</articles>
Je peux afficher tous les articles avec le code suivant:
<?php
$xmldoc = new DOMDocument();
$xmldoc->load('test.xml');
$xpathvar = new Domxpath($xmldoc);
$queryResult = $xpathvar->query('//articles/article'); // works fine grabs all articles
foreach($queryResult as $result){
echo $result->textContent;
}
?>
Je ne peux pas travailler sur la façon de montrer à un article basé sur ID.
Toute aide serait géniale.
Merci Stefan
Merci qui a travaillé un régal! – StefWill