Reading XML from Java

You can use Java API for XML Processing (JAXP) for processing the XML document using your java code. This API has all the classes needed to work with XML documents. It has all the necessary methods and properties for manipulating the XML documents.



For those who have worked with other scripting languages and programming languages to manipulate the XML documents, using the java code and the JAXP would be easy. The logic is the same but only the methods and properties might vary. Basic knowledge of object oriented programming would help you though.

To read the XML document from java code, you need a document object first. This is created in three steps using the JAXP. First a DocumentBuilderFactory is created and then a DocumentBuilder is created. Then finally a Document object is created.

The XML file is loaded into it and then certain methods like getElementsByTagName() are used to retrieve all the elements of a particular name and store them in an array called NodeList. This NodeList is looped through using a 'for' loop or some other way to get all the values needed.



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.