Which XPath tool can handle a large (50k+) amount of xml lines?

143 Views Asked by At

I've been trying vs-code- and notepad++ plugins, chrome devtools and countless online xPath evaluator tools to evaluate a big chunk of xml lines that throwed different kind of exception like callstack size, rangerror, memory etc. or the program crashed and other misfortunes.

Which XPath evaluator tool do you suggest that can handle a large amount of lines without a problem?

2

There are 2 best solutions below

0
kjhughes On

Tool recommendations are offtopic on this site, but here are some tips: Assuming an average of 80 char/line, a 50k line file would only be 4M chars, which is not considered to be large these days. Any XPath tool that cannot handle such sizes should be avoided. Editor plugins and online tools tend to be less capable than command line tools (xmlstarlet, xmllint, etc) or, even better, commercial tools (Saxon, oXygen, etc). Finally, should you have to process truly large XML files, consider streaming parsers such as SAX or StAX that do not have to build in memory data structures with sizes proportional to document size.

0
Michael Kay On

For what it's worth, if you run the query count(//*) (to count the number of elements) using Saxon on a 120Mb input file, from a cold start, it takes 270ms to compile the query, 1.5s to parse the source document, and 50ms to evaluate the query (the answer is 1666315). With a warm start the execution time comes down to about 20ms. That kind of size is not really considered especially large these days; though it might be large for a tool that's primarily an editor, because you need much more complex data structures to support editing rather than just searching.