Is XMLReader a SAX parser, a DOM parser, or neither?

前端 未结 4 1335
盖世英雄少女心
盖世英雄少女心 2020-12-21 02:24

I am testing various methods to read (possibly large, with very frequent reads) XML configuration files in PHP. No writing is ever needed. I have two successful implementa

4条回答
  •  感动是毒
    2020-12-21 02:48

    A SAX parser is a parser which implements the SAX API. That is: a given parser is a SAX parser if and only if you can code against it using the SAX API. Same for a DOM parser: this classification is purely about the API it supports, not how that API is implemented. Thus a SAX parser might very well be a DOM parser, too; and hence you cannot be so sure about using less memory or other characteristics.

    However to get to the real question: XMLReader seems the better choice because since it is a pull parser you request the data you want quite specifically and therefore there should be less overhead involved.

提交回复
热议问题