When should I choose SAX over StAX?

前端 未结 6 779
青春惊慌失措
青春惊慌失措 2020-12-07 08:25

Streaming xml-parsers like SAX and StAX are faster and more memory efficient than parsers building a tree-structure like DOM-parsers. SAX is a push parser, meaning that it\'

6条回答
  •  不思量自难忘°
    2020-12-07 08:59

    It's all a balance.

    You can turn a SAX parser into a pull parser using a blocking queue and some thread trickery so, to me, there is much less difference than there first seems.

    I believe currently StAX needs to be packaged through a third-party jar while SAX comes free in javax.

    I recently chose SAX and built a pull parser around it so I did not need to rely on a third-party jar.

    Future versions of Java will almost certainly contain a StAX implementation so the problem goes away.

提交回复
热议问题