Using java to write XML documents

The basis to work with an XML document or to create an XML document from the scratch is to have a document object in place. So, your first task should be to create a document object using the classes and methods available for that purpose in Java.

_______________________________________________


_______________________________________________

Creating a document object involves three steps. The first is to create a DocumentBuilderFactory object. The second is to create a DocumentBuilder object with that DocumentBuilderFactory object. Now in the third step you can create the Document object using the Document Builder object. A typical code should be,

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.newDocument();

You can use the getDocumentElement() method to get the root node and then you can use the appendChild() method to append the elements created, to the root node. To create the text nodes, you can use the method createTextNode() of the document object.

Manipulating the existing XML document is also possible and there are methods to traverse the nodes and to change them or to remove them. You can also traverse the nodes and then create attributes.

Where Android beats the iPhone (InfoWorld via Yahoo! News)
Can Google Android phones compete with the Apple iPhone? A few weeks ago, Google loaned me a Nexus One smartphone for experimentation, and I've spent the time since downloading applications and writing my own code. The good news is that the platform is not only competitive but is often a better choice than the iPhone for many programmers and the enterprises that employ them.

Skype lands in Nokia's Ovi Store (CNET)
The free Skype app for Symbian smartphones is now available from Nokia's Ovi store.



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