In this tutorial, you will see how to get text of element of xml file.
In this tutorial, you will see how to get text of element of xml file.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:
GetElementText
.java
package roseindia;
|
Output:
Text : This is programming language book. After trim Text : This is programming language book. After normalization Text :This is programming language book. |