[jdom-interest] Divorcing Root Element from document!!

Alex Wang awang at niku.com
Tue Nov 7 15:17:59 PST 2000


I was trying to do things differently: I wanted to merge two or more XML
documents which conform the same DTD so that my root JDOM element (from the
1st file) will have all children elements of root elements from all files.
Is there an easy way of doing it?

I am running JDOM beta 4.

Thanks,
Alex

-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of bob mcwhirter
Sent: Tuesday, November 07, 2000 1:32 PM
To: royd at tsainc.com
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Divorcing Root Element from document!!


> I am trying to take the root element of one Document and append it as a
> child element on a second document... I continually get errors about it
> having a parent.  How do you divorce the root element from the Document?

Set the source Document's RootElement to null, methinks, after
you've suck out the RootElement that needs transplanting.

	Element root = doc.getRootElement();
	doc.setRootElement(null);

	// can now reparent root

 -bob

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com




More information about the jdom-interest mailing list