stax与sax dom trax的对比图(其中TrAX只是用来转换XSLT,另外三种用来解析或处理XML):
Feature | StAX | SAX | DOM | TrAX (Transformation API for XML) |
---|---|---|---|---|
API Type 解析方式 | Pull, streaming | Push, streaming | In memory tree | XSLT Rule |
Ease of Use 易用性 | High | Medium | High | Medium |
XPath Capability Xpath支持 | Not supported | Not supported | Supported | Supported |
CPU and Memory Efficiency CPU和内存性能 | Good | Good | Varies | Varies |
Forward Only 跳转 | Supported | Supported | Not supported | Not supported |
Read XML 写入 | Supported | Supported | Supported | Supported |
Write XML 读取 | Supported | Not supported | Supported | Supported |
Create, Read, Update, Delete 增 查 改 删的支持 | Not supported | Not supported | Supported | Not supported |
图中StAX与SAX中的Pull streaming 拖拉式流 与Push streaming 推式流 的可以理解为
拖拉式(pull streaming)解析的好处: