How to validate very large XML files?

前端 未结 11 2435
失恋的感觉
失恋的感觉 2020-12-16 15:44

How can I validate a large XML file (>100mb)? I try to open it with IE, FX & GC and it either crashes or doesn\'t do anything.

相关标签:
11条回答
  • 2020-12-16 16:12

    xmllint --stream

    Worked on a 1.2Gb file with memory limited to 500Mb:

    ulimit -Sv 500000
    xmllint --stream a.xml
    

    Without --stream, Linux kills the process, and without ulimit, my computer jams.

    I was not able however to get output from --xpath when using --stream: How to do command line XPath queries in huge XML files?

    Tested in Ubuntu 14.04, xmllint version 20901.

    0 讨论(0)
  • 2020-12-16 16:16

    Windows Version of XML Starlet:

    > xml val <xmlfile.xml>
    
    0 讨论(0)
  • 2020-12-16 16:18

    Liquid Studio Community Edition contains a Large File Editor which can also be used to validate XML files. Its not really got an upper limit on the size of the files you can open Terra-byte files open instantly on low spec machines, and its free.

    0 讨论(0)
  • 2020-12-16 16:25

    In Java, and I'm sure in other languages, there are solutions for reading in an entire XML file and processing it as a complete DOM, and solutions that process the XML as a stream in an event-driven way. You would want the second kind of solution, which never loads the entire file in memory. See SAX for a Java solution to the problem.

    0 讨论(0)
  • 2020-12-16 16:25

    in addition to dj_segfault's comment on phihag's answer, xmlstarlet is fortunately NOT dead. They've just released Version 1.3

    If you want a decent commandlinetool that can manipulate xml, xmlstarlet is perfect (and pretty fast).

    0 讨论(0)
  • 2020-12-16 16:26

    You could try the EditiX XML editor.

    If you load your document into EditiX and there are problems with the XML, eg. mismatched opening and closing tags, the editor will still load the file and in the bottom right corner of the screen you'll see a number displayed in red eg. a red "5" means there are five errors in the document.

    I've not tried a 100mb document but I've done over 15mb and it seemed quite happy.

    There's a free version.

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