creating a new empty document with DOM

A

Andy Fish

Hi,

I am wondering what is the "most standard" way of creating a brand new empty
document in DOM. I'm working in java using xerces but I would like to make
the code as portable as possible. I have found 2 ways of doing it:

1. new DOMImplementationImpl().createDocument(...);
2. new DocumentImpl();

but both these are in org.apache.xerces.

Any reason I should prefer one over the other? any better way of doing it?

thanks

Andy
 
M

Martin Honnen

Andy said:
I am wondering what is the "most standard" way of creating a brand new empty
document in DOM. I'm working in java using xerces but I would like to make
the code as portable as possible. I have found 2 ways of doing it:

1. new DOMImplementationImpl().createDocument(...);
2. new DocumentImpl();

but both these are in org.apache.xerces.

Any reason I should prefer one over the other? any better way of doing it?

The Sun 1.4 SDK has
javax.xml.parsers.DocumentBuilder
which you should create using the factory
javax.xml.parsers.DocumentBuilderFactory
and then you can call
getDOMImplementation()
on the document builder and on the returned object you can call the W3C
DOM Level 2
createDocument(...)
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top