How to use Java to create XML with DTD

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.




_______________________________________________

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________






 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

Copyright - © 2004 - 2017 - All Rights Reserved.