You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Zhaohua Meng <me...@hotlens.com> on 2001/04/24 18:15:55 UTC

construct a new dom tree

I'm new to using xerces. My project needs to split one html page into 
two based on the size of the DOM tree. The input is XHTML. My question 
is how to construct a new Document instance which is independent of the 
document of the DOM tree parsed.
I tried to use the following code:
===================================================
DOMParser parser = new DOMParser();
parser.parse(uri);
Document doc = parser.getDocument();

Document newDoc1 = doc.getImplementation().createDocument();
Document newDoc2 = doc.getImplementation().createDocument();

Element body1 = newDoc1.createElement("body");
Element body2 = newDoc2.createElement("body");

newDoc1.appendChild(body1);
newDoc2.appendChild(body2);
===================================================

Exception is thrown when "newDoc1.appendChild(body1)" is executed.
What's wrong with the above code? I could find APIs that will allow me 
to contruct a empty DOM.
Thanks,

Zhaohua Meng

Hotlens.com Inc.
http://www.hotlens.com

350 Fifth AVE
Suite 3113
New York, NY 10118
Phone: 212-465-1700
Fax:   212-465-1710
email: mengzh@hotlens.com



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org