creating a new empty document with DOM

Discussion in 'XML' started by Andy Fish, Dec 30, 2003.

  1. Andy Fish

    Andy Fish Guest

    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
     
    Andy Fish, Dec 30, 2003
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Dec 30, 2003
    #2
    1. Advertising

  3. Andy Fish

    Andy Fish Guest

    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/
    >
     
    Andy Fish, Dec 30, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wendy S
    Replies:
    1
    Views:
    6,366
    Darren Davison
    Aug 5, 2003
  2. Krzysztof Nogal

    Writing XML DOM Document - empty tag

    Krzysztof Nogal, Apr 11, 2006, in forum: Java
    Replies:
    5
    Views:
    2,757
    Arvind
    Apr 14, 2006
  3. Krzysztof Nogal

    Writing XML DOM Document - empty tag

    Krzysztof Nogal, Apr 11, 2006, in forum: Java
    Replies:
    0
    Views:
    372
    Krzysztof Nogal
    Apr 11, 2006
  4. Ion Freeman
    Replies:
    17
    Views:
    833
    Tom Anderson
    Jul 11, 2009
  5. SMH
    Replies:
    2
    Views:
    257
Loading...

Share This Page