In this tutorial, we will see how to get text value of an element from xml file by using JDOM toolkit. JDOM is a library used for manipulating xml file.
In this example we are create xml document with the help of SAXBuilder class. The SAXbuilder class builds the Document tree with the help of xml string. Example then reads the value of an element. The class SAXBulider is used for creating JDOM tree with the help of build() method. The getChild() method of Element class is used to get the child of given element. The getText() method returns text value of the element.Code:
Text : This is programming language book.
After trim Text : This is programming language book.
After normalization Text :This is programming language book.
Posted on: August 26, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles