How to parse XML easily and quickly in Java


Does java have any class libraries for parsing XML?  For example, process the following XML:

<?xml version="1.0" encoding="utf-8" ?>


 <book category="COOKING">

   <title lang="en">Everyday Italian</title>

   <author>Giada De Laurentiis</author>







Expected XML structured effect:

Java generally uses XPath to parse XML. Because it is not a set language, it will be longer to write, and it uses a lot of interfaces, and the API is more complex. The code should be written as follows:


File file=new File("/workspace/bookstore.xml");

Document document=new SAXReader().read(file);

public void test(){

List<Node> nodes = document.selectNodes("bookstore/book");

for(Node node:nodes){





XML parsing, with esProc SPL will be a lot easier, it encapsulates the XPath, and has rich and powerful set computing capabilities, so it is easy to deal with. For example, the above question only needs two lines:






XML parsing is generally used for calculation, so SPL can be used to calculate more easily, such as: Statistics of annual book sales; only one line needs to be added on this basis:


In fact, there are many cases where it is not convenient to parse XML in Java, but it is very simple to use esProc SPL. Please refer to XML data parsing and calculation

It's also easy to embed esProc into Java applicationsplease refer to How to Call an SPL Script in Java

For the installation, usage, free authorization and related technical information of esProc, please refer to Getting started with esProc