There are
many ways to create XML with DTD using Java. One of the straight ways
is to serialize to the file output stream. For this you can use the
code like,
_______________________________________________
_______________________________________________
PrintWriter
out = new PrintWriter(new FileOutputStream("users.xml"));
Now you
can use the out.println(); to generate the output as your desire. This
method is very straight forward. But what you generate using this method
might not be a valid XML. To get a valid XML you have to follow other
methods of creating XML with DTD.
The other
ways available are to use a combination of DOM and Xerces to serialize
to the file output stream, SAX and Xerces, JAXP and DOM to serialize
to a servlet output stream or use JAXP and SAX to serialize to the servlet
output stream.
Very simple
example of the above methods to create an XML file with DTD is available
in the URL http://www.javazoom.net/services/newsletter/xmlgeneration.html.
You can try these examples as they are easily understandable.
Linked by Thom Holwerda on Wed 22nd Feb 2006 19:04 UTC (New Mobile Computing)
"What would happen if the beginning of file systems embedded a driver for accessing the disk? If the driver was in some sort of neutral format (similar to the X Windows drivers), then any OS could access the file system!