You could look into the DataProvider class:

import fl.data.DataProvider;

var dp:DataProvider;
var myXML:XML = <order>
 <book>
  <title>Dictionary 1</title>
 </book>
 <book>
  <title>Dictionary 2</title>
 </book>
</order>;

dp = new DataProvider(myXML);
trace("dp length: ", dp.length);
var item:Object = dp.getItemAt(0);
trace("first item: ", item);
trace("item title: ", item.title);

So rather than storing just the title (in an array), you store each book node 
as an Object (Array of Objects).

regards,
Muzak

----- Original Message ----- From: "ACE Flash" <[email protected]>
To: "Flash Coders List" <[email protected]>
Sent: Thursday, March 19, 2009 6:11 PM
Subject: [Flashcoders] A very simply question of XML toString()


Hey there,

I was trying to parse the XML to get all value of <title> and store them
into array at once. Do I have to use loop to push them into an Array or
there is a shortcut for doing this?

I'd like to get something like this...

var arr:Array = new Array();

// to trace arr
arr[0] = Dictionary 1
arr[1] = Dictionary 2

Thank you



  1. var myXML:XML =
  2. <order>
  3. <book>
  4. <title>Dictionary 1</title>
  5. </book>
  6. <book>
  7. <title>Dictionary 2</title>
  8. </book>
  9. </order>;
  10. trace( myXML.book.title.toString() )
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to