A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: creating xml in flash5 (doing my head in)

  1. #1
    Junior Member
    Join Date
    May 2001
    Posts
    1
    hi

    here's some really basic code.

    --------------------------------------------
    myXML = new XML();

    loginElement = myXML.createElement("LOGIN");

    myXML.attributes.username = "me";
    myXML.attributes.password = "secret";
    myXML.appendChild(loginElement);

    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 !!!

  2. #2
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    Remember your creating a tree:

    Code:
    //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
    myxml.firstChild.appendChild(login);
    //whats the output?
    trace(myxml.toString())

    the output window displays:

    Code:
    <login password="secret" username="me"></login>
    Hope that helps!
    [Edited by FlashGuru on 05-02-2001 at 08:41 AM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center