January 26, 2002 - Copying DOMDocuments | WebReference

January 26, 2002 - Copying DOMDocuments

Yehuda Shiran January 26, 2002
Copying DOMDocuments
Tips: January 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

You can copy the content of one DOMDocument object to another with the save() method. Call the source DOMDocument's save method with the other object as a parameter. The following function defines two DOMDocument objects, xmldoc and xmldoc2. We first read the external mydvd.xml file into xmldoc, and then copy its content to the xmldoc2 object:

function load() {
  var xmldoc;
  xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xmldoc2 = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xmldoc.async = false;
// -->
Let's call this script now. The alert box shows the content of xmldoc2.