A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Need Help Writing my XML !!!!

  1. #1
    Member
    Join Date
    Nov 2000
    Posts
    65
    Here's my Flash code:
    Code:
    loginXML = new XML();
    id1 = loginXML.createElement("BODY");
    id1.attributes.id = "mylink";
    loginXML.appendChild(id1);
    loginXML.contentType = "text/xml";
    loginReplyXML = new XML();
    loginReplyXML.onLoad = onLoginReply;
    loginXML.sendAndLoad("xmlreader.php", loginReplyXML);
    Here's What I get when I write my XML file:

    < BODY id="mylink" />

    Here's What I want it to look like:

    < BODY id="myVariable" >mylink< /body >




    What am I doing wrong???!

    Thanks in advance...


  2. #2
    New Title:
    Join Date
    Jul 2002
    Posts
    87
    You'll want to use createTextNode for the text inside the element.

    Code:
    loginXML = new XML();
    id1 = loginXML.createElement("BODY");
    
    // do this:
    text1 = loginXML.createTextNode("mylink");
    id1.appendChild(text1);
    // not this:
    // // id1.attributes.id = "mylink";
    
    loginXML.appendChild(id1);
    ...

  3. #3
    Member
    Join Date
    Nov 2000
    Posts
    65
    Originally posted by shoehorn
    You'll want to use createTextNode for the text inside the element.

    Code:
    loginXML = new XML();
    id1 = loginXML.createElement("BODY");
    
    // do this:
    text1 = loginXML.createTextNode("mylink");
    id1.appendChild(text1);
    // not this:
    // // id1.attributes.id = "mylink";
    
    loginXML.appendChild(id1);
    ...
    That's not really working...? Here's my code:

    Code:
    loginXML = new XML();
    id1 = loginXML.createElement("BODY");
    text1 = loginXML.createTextNode("mylink");
    id1.appendChild(text1);
    loginXML.appendChild(id1);
    And this is what my XML looks like:
    < BODY >mylink< /BODY >

    This is what I want it to look like:
    < BODY id="myVariable" >mylink< /BODY >

  4. #4
    New Title:
    Join Date
    Jul 2002
    Posts
    87
    The id="myVariable" part is an attribute of the element, which you had tried in your first sample. So here's what you want:

    Code:
    loginXML = new XML();
    id1 = loginXML.createElement("BODY");
    id1.attributes.id = "myVariable";
    text1 = loginXML.createTextNode("mylink");
    id1.appendChild(text1);
    loginXML.appendChild(id1);

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