xmlstarlet sel上的大文件 [英] xmlstarlet sel on large file

查看:148
本文介绍了xmlstarlet sel上的大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命令

  $ xmlstarlet sel -t -c/ collection / recordfile.xml 

似乎在应用给定的Xpath表达式之前将整个文件加载到内存中。这不适用于大型XML文件。



xmlstarlet 提供流式模式, xmlstarlet将所有(或大多数)操作转换为xslt转换,所以简短的答案是no。

/ p>

您可以尝试使用 stx ,这是类似于xslt的流转换语言。另一方面,只需在python中使用 sax 或< a href =https://docs.python.org/3.4/library/xml.etree.elementtree.html#xml.etree.ElementTree.iterparse =nofollow> iterparse 可能更容易,更快捷(wrt创建代码所需的时间)如果你不关心xml那么多。


The command

$ xmlstarlet sel -t -c "/collection/record" file.xml

seems to load the whole file into memory, before applying the given Xpath expression. This is not usable for large XML files.

Does xmlstarlet provide a streaming mode to extract subelements from a large (100G+) XML file?

解决方案

Xmlstarlet translates all (or most) operations into xslt transformations, so the short answer is no.

You could try to use stx, which is streaming transformation language similar to xslt. On the other hand, just coding something together in python using sax or iterparse may be easier and faster (wrt time needed to create code) if you don't care about xml that much.

这篇关于xmlstarlet sel上的大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆