Good afternoon!

Citizens, please advise how best to parse the big XML that comes through URLConnection , that is, from the web, that is, from this stream:

 BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); 

As I understand it, you need to choose between SaxParser and the usual manual processing of each XML string for the content of its tag.

What is faster? Will SaxParser thread where there will be a couple of hundreds of thousands of tags? What is the limit of such an XML loading system in terms of speed and volume?

  • Kaneshno pull. - Ilya Nikolaev
  • Thank you all for the answers! Stax is really nice, simple and fast. - KutaBeach

2 answers 2

How fast parse big XML

If it’s about the speed of the final application, and not the programming speed, then the usual manual processing can have some gain in speed (if the bottleneck is not data reading, but processing). But it all depends on the specifics of the problem.

Regarding SAX - sax parser climbs any amount of data.

Perhaps in some cases it will be faster than StAX (than SAX). For example, you need to find out if there is a word "yyy" in the document? It was found in the middle of the document. The rest of the document can not even read. SAX, will read.

    SaxParser is created to read from the stream. It does not load all hml in memory to read a certain piece of xml ...