W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1999

Re: help on DOM programming

From: Arnaud Le Hors <lehors@us.ibm.com>
Date: Thu, 16 Dec 1999 17:44:24 -0800
Message-ID: <38599578.A9692844@us.ibm.com>
To: Jian Chen <jchen@smartcad4.me.wisc.edu>
CC: www-dom@w3.org
There are actually several problems with your program. The first one is
that you simply can't use clone for that, because it only allows you to
clone nodes within a single document. What you need to use is the DOM
Level 2 method importNode instead.
Second, I don't understand why you need to get any DocumentFragment
involved in this. All you need to do is something like:

   NodeList NL = resultDoc1.getElementsByTagName("Part");

   Document resultDoc2 = DOMUtil.createDocument();
   Element root2 = resultDoc2.createElement("ROWSET");
   resultDoc2.appendChild( root2 );

  int k;
  // store the following since it can be expensive
  int l = NL.getLength();
  for (k=0;k<l;k++){

     Element row_ele = resultDoc2.createElement("ROW");
     Node imported = resultDoc2.importNode(NL.item(k), true);

    catch (DOMException e) {

Otherwise, if you have questions specific to XML4J, please refer to
www.alphaworks.ibm.com. This mailing list is only intended for
discussions on the _design_ of the DOM.
Arnaud  Le Hors - IBM Cupertino, XML Technology Group
Received on Thursday, 16 December 1999 20:45:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:06 UTC