Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > creating a new empty document with DOM

Reply
Thread Tools

creating a new empty document with DOM

 
 
Andy Fish
Guest
Posts: n/a
 
      12-30-2003
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


 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-30-2003


Andy Fish wrote:

> 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(...)

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
 
Andy Fish
Guest
Posts: n/a
 
      12-30-2003
Thanks Martin, I'll get that lot into my code right away.

Andy


"Martin Honnen" <> wrote in message
news:3ff18710$...
>
>
> Andy Fish wrote:
>
> > 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(...)
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading a simple XHTML transitional document into aorg.w3c.dom.Document Ion Freeman Java 17 07-11-2009 10:17 PM
Building SVG document Using DOM Interface Inside HTML Document SMH Javascript 2 03-18-2007 08:57 AM
Writing XML DOM Document - empty tag Krzysztof Nogal Java 5 04-13-2006 11:07 PM
Writing XML DOM Document - empty tag Krzysztof Nogal Java 0 04-11-2006 08:19 AM
Help with JDOM, turn org.jdom.Document -> org.w3c.dom.Document? Wendy S Java 1 08-04-2003 11:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57