DOM appendChild??

  • Thread starter Juliano Freitas
  • Start date
J

Juliano Freitas

I have to append in a xml file as a child another xml file. How can i
get this?

i try parent.appendChild(document)

but doesnt work!!

Juliano Freitas
 
T

Thomas Guettler

Am Sun, 31 Oct 2004 21:12:47 -0300 schrieb Juliano Freitas:
I have to append in a xml file as a child another xml file. How can i
get this?

i try parent.appendChild(document)

but doesnt work!!

Hi,

this is not possible. Try to add the root node (top level
tag).

HTH,
Thomas
 
A

Andrew Clover

Juliano Freitas said:
I have to append in a xml file as a child another xml file. How can i
get this?
i try parent.appendChild(document)

A node from one document can't directly be inserted into another. You
need to call Document.importNode first. Also you can't put the
Document node directly into a parent, because it is by definition the
root object of the entire DOM tree. What you probably want to do is
insert the root element node, which you can read with
Document.documentElement:

el= parent.ownerDocument.importNode(document.documentElement, True)
parent.appendNode(el)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Incrementing getelementbyid 1
remove child in DOM?? 0
C# list/array of Images to JS 0
document as child in DOM ?? 3
create a XML file with DOM 2
Sax Handler 1
SAX parse string to Handler?? 1
Javascript DOM 1

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top