[jdom-interest] How to use importNode in JDOM

Alex Rosen arosen at novell.com
Mon Mar 3 07:32:46 PST 2003


Use clone() or detach() - see the JDOM FAQ.

Alex

>>> "Raju Mukherjee" <raju at noospherics.com> 3/2/2003 1:43:49 PM >>>
Hi Brett,

I read you article in developer works on importing a childNode or
Element from one document to another document using DOM.
http://www-106.ibm.com/developerworks/xml/library/x-tipmvdom.html 

I wnat to do the same with JDOM. couldn't figure out how to do that.
This is what i am trying to do:

a) I have a template.xml

    <root>
        <element1>
            <child1/>
            <child2/>
        </element>
    </root>
b) I want to create a new xml from the template.xml . Also a outside
process result will tell be how mant <element1> should the new document
have under <root>
c) So if the outside process ask me to add 2 such <element1> child
under the new xml file's <root>, I would have to take the template of
<element1> from the "template.xml" and add that 2 times under <root> to
get my new xml file.
---------------basically adding row to a database.

You have nicely show that using w3c.dom.Node....but how would I do it
in JDOM.

Any help is appreciated.

Raju



More information about the jdom-interest mailing list