Return to Snippet

Revision: 20001
at November 4, 2009 12:54 by chrisaiv

Initial Code
var products:Array = new Array();

products.push({name:"Laptop", id:111, price:2999.99});
products.push({name:"Mouse", id:222, price:49.99});
products.push({name:"Phone", id:333, price:199.99});

var inventory:XML = <inventory/>;

for each (var o:Object in products)
	inventory.appendChild(<product id={} price={o.price}>{}</product>);

Initial URL

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

Initial Title
AS3: Generating Dynamic XML With E4X in ActionScript

Initial Tags

Initial Language
ActionScript 3