开发者

What is the most memory efficient method to parse XML in java?

I have memory problems with the webapp responsible from parsing XML event and pushing them to our RabbitMQ bus. This webapp receives XML event in a servlet, we decode it and push it to our bus and then we acknowledge the sender. We are curently using org.xml.sax.helpers.DefaultHandler in java 5, but it seems that Stax (with XMLStrea开发者_开发百科mReader) is much better and still easy to read, but we would need to migrate our code to java6 (see this question on SO). Does it worth it ?

What is the most memory efficient method to parse XML in java ? We are looking for a fast, memory efficient and easy to write/read code. Does this exist ?


Event-driven parsers don't build up ASTs and are therefore fast and memory-efficient. The standard for XML would be defined by the SAX standard.

The Xerces implementation claims to be fast.


NanoXML is a very small and lightweight XML parser which supports SAX parsing. It is a good alternative to Xerces.


Beware of the answers mentioning Sax, as it is at the expense of significantly less usefulness. The most memory efficient sax parsing w/o sacrificing usability is vtd-xml. Here is the proof

Processing XML with Java – A Performance Benchmark http://sdiwc.us/digitlib/journal_paper.php?paper=00000582.pdf

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜