Salut les mecs,
Je suis entrain de réaliser une application en flash en utilisant XQuery pour faire des traitements sur mon fichier XML que voici:
et voici mon code Action Script :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="fr">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
Au niveau l'affichage j'ai exactement le résultat voulu, mais quand je veux par exemple mettre une condition ça ne marche pas. J'ai mis ça :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import com.xfactorstudio.xml.xpath.*; var _xml:XML = new XML(); _xml.ignoreWhite = true; _xml.onLoad = function(success:Boolean) { if (success) { var title_array:Array = XPath.selectNodes(this.firstChild, "/bookstore/book/title"); var author_array:Array = XPath.selectNodes(this.firstChild, "/bookstore/book/author"); var rssData:Array = []; for (var i:Number = 0; i<title_array.length; i++) { rssData.push({Author:author_array[i].firstChild.nodeValue, Title:title_array[i].firstChild.nodeValue}); } myGrid.dataProvider = rssData; myGrid.getColumnAt(0).width = 180; } else { trace("unable to load XML"); } }; _xml.load("test.xml");
dans le but d'afficher que les infos du premier livre, mais ça ne retourne rien. Avez vous une idée?Code:
1
2 var title_array:Array = XPath.selectNodes(this.firstChild, "/bookstore/book/title[@lang=en]");
Merci