Creating XML with DTD in Java

Creating XML with DTD can be done using Java in many ways. One of the easiest ways to do that is to serialize the data to a file output stream. You can do this by using a statement like,

PrintWriter out = new PrintWriter(new FileOutputStream("urfile.xml"));

In the above statement you can create an XML file 'urfile.xml' by using the FileOutputStream and creating a new PrintWriter object. Once you create this object it is straightforward to use the statement using out.println(); to generate any type of output you want to your XML file.

However the XML file that is generated with the DTD using this method might not a valid XML file. The tag to include the DTD within the XML file also has to written to the stream using such statements.

The other combinations that can be used to create XML with DTD are to use DOM and Xerces, SAX and Xerces, JAXP and DOM, or JAXP and SAX. Check the following URL

http://www.javazoom.net/services/newsletter/xmlgeneration.html for some sample code by using the straightforward PrintWriter method.



.

SetApp - 100 Apps for everything you ever wanted to do on Mac

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

 

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.