更新时间:2023-11-25 11:22:34
我会推荐这种JavaScript或流解析器的基于SAX的解析器。
I would recommend a SAX based parser for these kind of JavaScript or a stream parser.
DOM解析会将整个内容加载到内存中,这不是大文件的方法就像你提到的那样。
DOM parsing would load the whole thing in memory and this is not the way to go by for large files like you mentioned.
对于基于Javascript的SAX解析(XML格式)
你可以参考
https://code.google.com/p/jssaxparser/
和
对于JSON
您可以编写自己的,以下链接演示如何在Javascript
中编写一个基于SAX的基本解析器 http://ajaxian.com/ archives / javascript-sax-based-parser
for JSON
you might write your own, the following link demonstrates how to write a basic SAX based parser in Javascript
http://ajaxian.com/archives/javascript-sax-based-parser