Click to See Complete Forum and Search --> : creating xml in flash5 (doing my head in)

05-02-2001, 07:40 AM

here's some really basic code.

myXML = new XML();

loginElement = myXML.createElement("LOGIN");

myXML.attributes.username = "me";
myXML.attributes.password = "secret";

trace (myXML.toString());

the output i get from this is

password="me" username="secret" <LOGIN />

as you can see, its malformed mssing the opening tag. When I send this to an asp page it obviously falls on its bum as the xml is bad.

Why on earth is this happening? Can anyone help? PLEASE PLEASE OH GOD PLEASE !!!

05-02-2001, 08:35 AM
Remember your creating a tree:

//create a new xml object
myxml=new XML()
//create a new xml element
myxml.appendChild((new XML()).createElement("login"));
//set the attributes of this node
myxml.firstChild.attributes.username = "me";
myxml.firstChild.attributes.password = "secret";
//close the node
//whats the output?

the output window displays:

<login password="secret" username="me"></login>

Hope that helps!
[Edited by FlashGuru on 05-02-2001 at 08:41 AM]