Posted By

chrisaiv on 11/04/09


Tagged

xml as3


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

jasonm23
ClayVillage
donaldleegraham
tspitzr
dubogii


AS3: Generating Dynamic XML With E4X in ActionScript


 / Published in: ActionScript 3
 

URL: http://blogs.adobe.com/cantrell/archives/2009/10/generating_dynamic_xml_with_e4x.html

Here's how you can generate XML dynamically and use variables as attribute values or text nodes.

  1. var products:Array = new Array();
  2.  
  3. products.push({name:"Laptop", id:111, price:2999.99});
  4. products.push({name:"Mouse", id:222, price:49.99});
  5. products.push({name:"Phone", id:333, price:199.99});
  6.  
  7. var inventory:XML = <inventory/>;
  8.  
  9. for each (var o:Object in products)
  10. {
  11. inventory.appendChild(<product id={o.id} price={o.price}>{o.name}</product>);
  12. }

Report this snippet  

You need to login to post a comment.