[jQuery] parsing xml with jquery adding filter
hello,
I'm trying to parse some info from an XML file with a filter to get
only one part of a the infos.
it doesn't seem to work.
can someone help.
here is my code:
function getImageName(marque) {
$.get("xml/listeProduits.xml",{},function(xml){
// Build an HTML string
var nom = new Array();
$('marque',xml).filter(function(index) {return $
(this).find("marque").attr("id") == marque}).each(function(i) {
nomRef = $(this).find("nom").text();
promotion = $(this).find("promotion").text();
//nomMarque = $(this).find("marque").attr("idMarque");
var variableTableau = new valeurTab (nomRef,promotion);
nom[i] = variableTableau;//buildDiapo (nom);
});
for (h=0;h<nom.length;h++) {
$('#diaporama').append('<img src="images/'+nom[h].nomProduit
+'.jpg" width="80" height="108" />');
}
$('#diaporama').cycle({
pause: 1,
random: 1,
after: onAfter });
});
}
here is my xml file
<listeArticle>
<marque id="Oakwood">
<produit>
<nom>rumba_beige</nom>
<promotion>oui</promotion>
</produit>
<produit>
<nom>crawford</nom>
<promotion>non</promotion>
</produit>
</marque>
<marque id='Redskins'>
<produit>
<nom>lennyc</nom>
<promotion>oui</promotion>
</produit>
<produit>
<nom>citizen</nom>
<promotion>non</promotion>
</produit>
</marque>
</listeArticle>