SAX parser vs XMLPull parser

后端 未结 7 1273
长情又很酷
长情又很酷 2020-12-12 16:38

I understand the difference between how the SAX parser works vs the XMLPull parser. In fact there\'s a pretty good explanation here:

http://www.firstobject.com/xml-r

相关标签:
7条回答
  • 2020-12-12 17:18

    It totally depends on the situation for e.g If the xml file is really large than you can't opt for DOM parsers as they will first bring the file in to memory and then it will be parsed and i found that parsing a file of size n requires 7n memory space. In this case you should opt for SAX parser its light and will consume less memory.

    Second case is when the file is not really large, in this case you can go for XML pull parser because in this you will have full control on the xml you can skip the parsing cycle any where that is not possible in SAX. So if the tag you are looking for is the first one in the file then why would you go for whole file.

    So as far as i know if you consider only speed with small file go with XML pull parser and If the file is large and you want to parse it all then go with SAX.

    0 讨论(0)
提交回复
热议问题