4 ms·
I was recently downloading and parsing the US Patent application database, which is emitted in XML. In 2023, Python lxml can't handle multiple documents per fi
by XorNot 4y ago
I was recently downloading and parsing the US Patent application database, which is emitted in XML.
In 2023, Python lxml can't handle multiple documents per file. And no one has any suggestions on how to handle this other then "break on the new document tag". Other libraries didn't look promising in other languages.
Then if you try to read it, you need to disable all the DTD stuff because it immediately tries to open other local files on disk...which it can't find. There's some corruption in how it parses DTDs because I had to implement a custom DTD handler in my jupyter-notebook to read it.
I could blame the dominant XML processing library of Python, I could blame the lack of attention XML gets, but really? This is just another contribution in a long line of XML not working in some way in every language as soon as you're not using that languages specific XML flavor.
- dehrmann 4y agoI'm curious how Java would handle this. Its XML support is usually very mature. Java and JSON is a different story. There was a window when the only JSON parser Java shipped with was JSON.parse() in its Javascript interpreter.
- DonHopkins 4y ago"Java is a DSL for taking large XML files and converting them to stack traces." -Andrew Back https://www.reddit.com/r/programming/comments/eaqgk/java_is_a_dsl_for_taking_large_xml_files_and/ https://www.reddit.com/r/programming/comments/eaqgk/java_is_... "I Wanna Be <![CDATA[" Sung to the tune of “I Wanna Be Sedated”, with apologies to The Ramones. https://donhopkins.medium.com/i-wanna-be-cdata-3406e14d4f21 https://donhopkins.medium.com/i-wanna-be-cdata-3406e14d4f21
- nrclark 4y agoI haven't had to work with XML all that often. For the few programs I've made that need to speak XML, I've always used the XML module in Python's stdlib. Is that bad practice? What does lxml provide as a benefit?