xmlstarlet sel on large file

前端 未结 2 1916
忘掉有多难
忘掉有多难 2020-12-16 23:26

The command

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

seems to load the whole file into memory, before applying the given Xpat

相关标签:
2条回答
  • 2020-12-17 00:05

    Since I only needed a tiny subset of XPath for large XML files, I actually implemented a little tool myself: xmlcutty.

    The example from my question could be written like this:

    $ xmlcutty -path /collection/record file.xml
    
    0 讨论(0)
  • 2020-12-17 00:25

    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.

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