Flex 4 和大型 XML 文件
有人有处理大型本地 XML 文件的经验吗? 假设有 100.000 行。
在 AIR 上运行 Flex 4.5 时实现这一点的可行性如何?
谢谢。
Does anyone have experience with working with large local XML files?
Let's say 100.000 lines.
How feasible is it to do that with Flex 4.5 running on AIR?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是理论上它会起作用。但它的工作速度会非常慢。 e4x 会遍历,但没有任何 API 可以告诉您对根子节点的操作何时完成。它会给人一种你的应用程序挂起的印象。过去有 4GB 文件参考大小的限制,但我相信情况已经改变。我不确定 AIR 是否适应 32 位和 64 位系统之间的差异。在32位的情况下,有2GB的限制,当突破时,运行时将抛出flash.errors.MemoryError。 100,000 行 XML 并不算太糟糕,但如果存在各种名称空间、大量文本 blob 和开始/结束标记,它可能会变得相当臃肿。
The answer is it will work, in theory. But it will work very slow. e4x will traverse but there is nothing API wise that will tell you when an operation on the root's children will complete. It will give the impression that your app is hanging. There used to be a limitation of 4GB file reference size but I believe things have changed. I'm not sure if AIR is attuned to the difference between 32-bit and 64-bit systems. In the case of 32-bit, there is 2GB limit that when broken a flash.errors.MemoryError will be thrown by the runtime. 100,000 lines of XML is not too bad but it can get pretty bloated if there is all kinds of namespaces, massive text blobs and the opening/closing tags.
如果您不需要完整的 XML 语法来解析文件,您可以考虑创建自定义解析器(类似于 SAX)而不是默认的 DOM 模型。打开该文件,逐行读取并将信息流式传输到 SQLite(对于非索引表来说,大量插入或多或少会更快。)这将让您在有限的部分中完成工作,而无需 GUI 冻结(尽管可能不是)对于一次性转换很重要。)
If you don't need full-blown XML syntax for parsing your files, you might consider creating custom parser, sort of SAX instead of default DOM model. Open that file, read line by line and stream the info into SQLite (lots of inserts will be more or less fast for non-indexed table.) This will let you do the job in limited portions without GUI freeze (although it may be not important for one-time conversion.)