Using Java to generate XML

With Java you can generate XML in many ways. One of the ways is to write the XML code using the out.println() statement and generate the XML file you need using the PrintWriter. However this method is very straightforward and there is no guarantee that the generated XML file would be error free.

_______________________________________________


_______________________________________________

Another way is to use the Java API for XML Processing. By using this method you can create a document object and then create the different elements of the XML file using the Element object. The document object has methods for this purpose.

Methods like appendChild() and createTextNode() are used in creating the text nodes and then adding them to the root node of the XML document.

One another way to generate XML from Java is to serialize the Java objects in to XML using the XStream class. With this method you can easily serialized the Java objects to XML. For example if you have a class 'person', you can serialize that with the statement,

String xml = xs.toXML(person);

In the above statement 'xs' is the XStream object. To work with this object you have to import com.thoughtworks.xstream.XStream.

Blog change? Ads? What gives? (Java World)
Submitted by Ted Neward on Wed, 07/16/2008 - 19:29. If you've peeked at my blog site in the last twenty minutes or so, you've probably noticed some churn in the template in the upper-left corner; by now, it's been finalized, and it reads "JOB REFERRALS".

MDA Approach - Part 1 (Java World)
Submitted by lal on Wed, 07/16/2008 - 04:12. Tags: Model Driven Architecuture [MDA] is a model driven engineering approach provided by OMG. It provides a set of guidelines for structuring specifications [for eg. business functionality] expressed as models.

Linked by Eugenia Loli-Queru on Fri 25th Aug 2006 23:55 UTC (OS News)
Vista will be the last version of Windows that exists in its current, monolithic form, according to Gartner. Instead, the research firm predicts, Microsoft will be forced to migrate Windows to a modular architecture tied together through hardware-supported virtualisation.



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.

_______________________________________

Recommended XML Books

cover
cover
cover
cover
cover
cover





 

 

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!


New XML Books Titles - Best Seller's @ Amazon.com

Visit XML Training Material Guide Homepage

Technology helps engage students - how do classroom instruction and social dynamics change when the classroom is completely dependant on modern technology?

Dallas Web Design- local Dallas web design firm offers site design and backend system development