Which one is the best XML-parser?

dieter dieter at handshake.de
Fri Jun 24 02:39:47 EDT 2016


David Shi via Python-list <python-list at python.org> writes:

> Which one is the best XML-parser?

"best" is not an absolute term but depends on criteria/conditions.


There are essentially two kinds of parsers: incremental parsers
which parse the structure and report events for everything they see
and non-incremental parses which transform the complete XML
into a data structure.

You want an incremental parser if the XML documents are so huge that
you must process them incrementally rather than have a data structure
representing the whole document (in memory). Incremental parsers
for XML are usually called "SAX" parsers.

If your XML documents have moderate size, you might prefer
a non-incremental parser.


Personally, I like "lxml" (a binding to the "libxml2" C-library).
It supports a lot of features: besides simple parsing, it supports
verification against XML-schema and DTDs, XPath and XSLT-transforms.
This means, with one XML tool you can handle all tasks typically
encoutered with XML processing.

However, "lxml" depends on an external C-library ("libxml2").
Therefore, it might be considered more difficult to install
than "pure python" XML parsers.

These examples show: "best" depends on your situation, your tasks
and your preferences.





More information about the Python-list mailing list