Problem with 2 similar doms

T

theGirl

Hi,

Sorry for my english, I'm french !
I 'm using Ajax to build pages with xml files.
In my page, I want to have 2 doms for the same xml file : one for the
initials datas, ant another which will be modified by the web page.
When the user validate the page, the second dom is is copied into the
first.
So I have :
xmlDoc1 = http_request.responseXML;
xmlDoc2 = http_request.responseXML;

In my page, I have javascript code that modify nodes of the xmlDoc1,
but the xmlDoc2 is modified also, but I don't want this dom to be
modified !
What is the problem with my code ?

Thank you for your help
 
M

Martin Honnen

theGirl wrote:

xmlDoc1 = http_request.responseXML;
xmlDoc2 = http_request.responseXML;

In my page, I have javascript code that modify nodes of the xmlDoc1,
but the xmlDoc2 is modified also, but I don't want this dom to be
modified !

You simply have two variables with references to the same object.

You would need to clone the original document node e.g.
var xmlDoc2 = httpRequest.responseXML.cloneNode(true);

I think Opera 8 however does not support cloneNode on document node
objects, I get an exception when calling cloneNode(true) on an XML DOM
document node with 8.51.

Opera 9 preview also throws a NOT_SUPPORTED_ERR DOM exception.
 

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

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top