Create and write XML

Hi,

my app has to output an XML file with the results of the process, so I need to create the XML and write it to file.

It will be a small XML, and I' ve got the DTD syntax.

I use jdk 1.4, and only included libraries.

My question is, should I use SAX or DOM? JAXP? how to link with the DTD?

Examples are welcome.

Thanx!

[363 byte] By [txatia] at [2007-11-27 9:45:33]
# 1

SAX/DOM/JAXP come into picture when you have to parse an XML file. I don't see its use when you are trying to generate an XML file.

Since you have the DTD and you are the one to generate the XML, why do u need to validate generated XML against the DTD ? Instead, you can make sure that the logic you code to generate XML always generates valid XML w.r.t DTD. (... + an added advantage would be - time saving)

java_a at 2007-7-12 23:54:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
So you suggest to write a text plain file, not using SAX, DOM, ...? I thought that JAXP could help making/writing XML.
txatia at 2007-7-12 23:54:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

> So you suggest to write a text plain file, not using SAX, DOM, ...?

Yes

> I thought that JAXP could help making/writing XML.

(JAXP) enables applications to parse and transform XML documents ...

Refer http://java.sun.com/webservices/jaxp/

Transformation is something that converts one XML to some other XML or format. It has got nothing to do with generation of new XMLs.

java_a at 2007-7-12 23:54:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...