A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: appendchild to deeply nested large document

  1. #1
    Junior Member
    Join Date
    May 2000
    Posts
    26

    appendchild to deeply nested large document

    <?
    <main>
    <person>
    <name>sally</name>
    <email>sally@</email>
    </person>
    <person>
    <name>burt</name>
    <email>burt@</email>
    </person>
    <person>
    <name>roger</name>
    <email>roger@</email>
    </person>
    </main>
    ?>

    I'd like to change the name node of a particular person. Here's my code:

    newStore = new XML();
    //copy the whole doc
    node = _root.people.firstChild.cloneNode(true);
    newStore.appendChild(node);
    //
    name=newStore.firstChild.childNodes[k].firstChild.createTextNode("ralph");
    newStore.appendChild(name);
    socket.send(newStore);

    And this gives my a broken XML. Any help out there?

    Dos

  2. #2
    I'm not really sure what your trying to do. Are you trying to change the name of one person, or create a new XML object with one person cloned from a different object and change the name.

    If you just want to change the name of a person, just target the value and set it to your new value. For example, you can change sally to ralph with this, assuming you used ignoreWhite = true.

    people.firstChild.firstChild.firstChild.firstChild .nodeValue = "ralph";

  3. #3
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    At which point is the XML broken?

    Trace through the commands and find out which command is causing your XML to be broken,

    Also by the looks of it your code is adding a name to the XML rather than just changing it.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

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