bonjour a tous
voila mon probleme
j'ai besoin de creer une liste deroulante a partir d'un fichier xml
pour ce faire ( je pense que c'est la seule solution) j'utilise xsl
mais sa marche pas
voici mes codes :
xml :
1 2 3 4 5 6 7 8 9 10
| <produits>
<ecrans>
<ecran value="1" nom="-----------Ecran blouson-----------"></ecran>
<ecran value="2" nom="-----------Ecran casque------------"></ecran>
<ecran value="3" nom="-----------Ecran gant--------------"></ecran>
<ecran value="4" nom="-----------Ecran cross-------------"></ecran>
<ecran value="5" nom="-----------Ecran caisse------------"></ecran>
<ecran value="6" nom="--Ecran caisse pour moto occasion--"></ecran>
</ecrans>
</produits> |
php :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| $xh = xslt_create();
$fil=fopen("file/admin/produit.xml","r");
$xmls=fread($fil,16384);
fclose($fil);
$fil=fopen("template/pages/ecran.xsl","r");
$xsls=fread($fil,16384);
fclose($fil);
$arguments = array(
'/_xml' => $xmls,
'/_xsl' => $xsls
);
$resulte = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
xslt_free($xh); |
et plus loin pour afficher le select (toujour dans mon php):
<?php print "$resulte" ; ?>
et mon xsl :
1 2 3 4 5 6 7 8 9 10 11 12 13
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="ecran" />
<center><SELECT>
<xsl:for-each select="produits/ecrans/ecran">
<OPTION>
<xsl:attribute name="VALUE"><xsl:value-of select="@value"/></xsl:attribute>
<xsl:value-of select="@nom"/>
</OPTION>
</xsl:for-each>
</SELECT></center>
</xsl:template>
</xsl:stylesheet> |
si quelqu'un peu m'aider merci
Partager