Parsing XML files using JDOM
Unlike text data, which is often unstructured, organizing data in XML files is a popular method to prepare, convey, and exploit data in a structured way. There are several ways to parse contents of XML files. In this book, we will limit our recipes to an external Java library for XML parsing named JDOM.
In order to perform this recipe, we will require the following:
- Download version 2.06 of the JAR file for JDOM from http://www.jdom.org/downloads/index.html.
- In Eclipse, create a project and include the JAR file an external JAR.
- Open up notepad. Create a new file named
.xmlextension. The content of the file will be as simple as follows:
<?xml version="1.0"?> <book> <author> <firstname>Alice</firstname> ...