java and XML

T

tony vee

Hi

I have the following bit of Java code:

Document doc = tidy.createEmptyDocument();
//bodyElement is the body element in an HTML Document
Node first = bodyElement.getFirstChild();
Node top = doc.getDocumentElement();
top.appendChild(first);

which produces unexpected results. Basically, all I am after is getting the
first child node of the body element and copy it to the new document. But
what I get is the required element AND every element after it - every one of
the first elements siblings! I have tried so many variations of the above,
using DocumentFragments etc, but with no joy. In order to preserve the
little hair I have left, I would be grateful for any help

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top