Android: DOM vs SAX vs XMLPullParser parsing?

后端 未结 3 1599
鱼传尺愫
鱼传尺愫 2021-02-14 01:02

I am parsing XML Document using SAX Parser.

I want to know which is better and faster to work with DOM, SAX Parser or XMLPullPa

3条回答
  •  不知归路
    2021-02-14 01:39

    it depends on what are you doing , if you have very large files then you should use SAX parser since it will fire events and releasing them ,nothing is stored in memory ,and using SAX parser you can't access element in a random way there is no going back ! , but Dom let you access any part of the xml file since it keeps the whole file/document in memory . hope this answer you question .

    if you want to know which fastest parser Xerces is going to be the fastest you'll find and SAX parser should give you more performance than Dom

提交回复
热议问题