简体   繁体   English

XML解析(SAX,StAX)与扫描仪

[英]XML parsing (SAX,StAX) vs Scanner

The question is not related to comparison between different parsers, but it's related to the memory utilization and usage. 这个问题与不同解析器之间的比较无关,但与内存利用率和使用率有关。

My question is that which method is better to read exactly one line "two elements" of an XML file, the XML parsers or Scanner method? 我的问题是,哪种方法最好能准确地读取XML文件的一行“两个元素”,XML解析器或Scanner方法?

I will be running this script only once through 30 GB of XML files, so I thought of Scanner assuming it will be a faster method than xml parsing since I'm only reading certain lines from each object without manipulation or what so ever. 我将只通过30 GB的XML文件运行一次该脚本,因此我想到了Scanner,它假定它比xml解析更快,因为我只从每个对象读取某些行,而无需任何操作。

The speed is more than likely restricted by the speed of reading 30 GB of data, so either way of parsing will work. 该速度很可能受到读取30 GB数据的速度的限制,因此任何一种解析方式都可以使用。 SAX is very efficient and can read XML's as a stream, so memory usage should be low. SAX非常高效,并且可以将XML作为流读取,因此内存使用率应该较低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM