在Java中解析XML的最有效的内存方法是什么? [英] What is the most memory efficient method to parse XML in java?

查看:94
本文介绍了在Java中解析XML的最有效的内存方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用webapp时遇到内存问题,原因是解析XML事件并将其推送到RabbitMQ总线.此webapp在servlet中接收XML事件,我们对其进行解码并将其推送到我们的总线,然后我们确认发送者.我们目前正在Java 5中使用org.xml.sax.helpers.DefaultHandler,但似乎 Stax (使用XMLStreamReader)会更好,并且仍然易于阅读,但是我们需要将代码迁移到java6(请参见

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 XMLStreamReader) 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 ?

在Java中解析XML的最节省内存的方法是什么?我们正在寻找一种快速内存高效且易于编写/阅读的代码.是否存在?

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 ?

推荐答案

事件驱动的解析器不会建立AST,因此具有快速且内存高效的特点. XML标准由 SAX标准定义.

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.

Xerces实现声称速度很快.

这篇关于在Java中解析XML的最有效的内存方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆