How to create XML document using java

If you have already worked with some other scripting language or programming language in a document object then this will not be new to you.

_______________________________________________


_______________________________________________

To work with an XML document it is easy to do so, if you have a document object in place and the XML document loaded in it. Yes, java too has APIs for working with an XML document. With this API, you can navigate through the XML document, or create an XML document from the scratch.

import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;

DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
DocumentBuilder bd = fact.newDocumentBuilder();
doc = bd.newDocument();
Element rt = (Element) doc.createElement("rtElement");
document.appendChild(root);
rt.appendChild( doc.createTextNode("Some") );
. . .
. . .

Proper imports are to be done to work with the classes and the methods needed for working with an XML document. The above code sample would give you an idea on how to go about it. Methods like createElement of the Element object are used to create elements.

And these elements are added to the root node using the method appendChild. Lots of sample codes are available in the internet on this topic.

Tuning and Testing Enterprise Web Services with SoapUI and JMeter (Developer.com)
In this article, I will talk about two test tools for the enterprise web services tuning and testing.

How to use Multi-touch in Android 2: Part 2 (ZDNet)
To demonstrate multi-touch, we're going to build a simple image viewer application that lets you zoom in and scroll around an image. Begin by creating a new "Hello, Android" project with the following parameters in the New Android Project dialog box....


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?

Cisco CCNA Certification Video Tutorial Guide - Learn How to Pass the Cisco CCNA 640-802 Exam... Guaranteed!

Train Signal Computer Training