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.
Getting ready
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
xmldummy
with the.xml
extension. The content of the file will be as simple as follows:
<?xml version="1.0"?> <book> <author> <firstname>Alice</firstname> ...
Get Java Data Science Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.