473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

creating a new empty document with DOM

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
Jul 20 '05 #1
2 2637


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/

Jul 20 '05 #2
Thanks Martin, I'll get that lot into my code right away.

Andy
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:3f********@olaf.komtel.net...


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/

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
4
by: Marja Ribbers-de Vroed | last post by:
Hi, I'm using MSXML2.DOMDocument.4.0 to create an XML document on-the-fly. Everything is going great except that at some point I need to create an empty XML element with a start and an end tag,...
4
by: Bryan Dickerson | last post by:
Ok, I've spent all this time creating a program to read an XML Document via XPaths and my boss is pretty thrilled, but now I have to return an XML document, so can someone point me to some sample...
1
by: JackieWilson | last post by:
Hello! I', trying to create DOM based XML document. First I create XmlDocument object and then read other XML DOM Document and modifie the first one. I'm putting Noden and Attributes tto the...
2
by: stealth_spoof | last post by:
Hi People wondering if anyone can help me with a problem I'm having I'm trying to create an array with an unspecified length, the length is based on the result i get from another task in the code...
1
by: Rako | last post by:
My problem is: I want to create an index to any of the available picture-groups. This index is a table of thumbs with a scrollbar. If you click on the thumb, you get the full picture displayed. ...
1
by: Mikus Sleiners | last post by:
I have a task to create xml document from c# code. I have example of that document should look like and also a xml schema. I wonder if i can use this xml schema somehow ? This is schema: ...
5
by: Marian Steinbach | last post by:
Howdy! I am just switching from PHP4 to PHP5. Since there are many different ways to create XML in PHP5, I'd like to know from the community which one would be suited best for a REST web service...
3
by: A. W. Dunstan | last post by:
I've got a schema file (four, actually - one includes the other three) and am trying to create a 'sample' XML file from it. I tried reading the .xsd files myself but the four of them combined add...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.