How to use Java to create XML with DTDThere 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.
|
|
|||
|
||||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.