This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Solved] WRONG_DOCUMENT_ERR while appending child

 
Jeya Balaji
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
Got some error while appending a child node.
Here is what I did.
* There exist a .xml file with few elements.
* Using Dom, I loaded the document into the memory.
* Travelled to a particular node and tried appending a newly created node.
* This doesn't work; giving the error WRONG_DOCUMENT_ERR
The skeleton is :

The last statement throws DOMException.
After reading manual, api and books, I could get only the meaning of the error code :
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.

Is there a way to tell the document to accept any node that is created at runtime?
Any help is appreciated.
Thanks,
Balaji
[ January 22, 2003: Message edited by: Jeya Balaji ]
[ January 25, 2003: Message edited by: Jeya Balaji ]
 
Jeya Balaji
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had solved that problem with the following code :

that is, I used document instead of docImpl and document.getDocumentElement().appendChild instead of document.appendChild
Regards,
Balaji
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic