-
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
-
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";
-
Senior Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|