4 ms·
Two things where imho XML performs well: 1: text with markup. Does not need all the XML machinery, but tags make a lot of sense here. 1b: Arbitrarily nested s
by wongarsu 4y ago
Two things where imho XML performs well:
1: text with markup. Does not need all the XML machinery, but tags make a lot of sense here.
1b: Arbitrarily nested stuff
2: extensability by third parties without coordination. Namespaces as a central concept help out a lot here, and this use case can even justify some of the more insane features of XML (downloading remote schemas etc)
If you don't need either of those things, you won't get much value out of XML. If you do need them, XML can be neat. Certainly easier than trying to allow people to add arbitrary data (with validation) to your protobuf. It's just that these use cases are somewhat rare
- halayli 4y agoMore importantly, streaming.
- XorNot 4y agoI 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?
- dehrmann 4y agoXML tends to be more feature-rich than people need, but what's really lacking in JSON is any support for using custom types to disambiguate polymorphism. I can't seem to find it, but there's a serialization that's basically Python, so Stuff(a=10, b={"foo": bar}) It makes it easy to have a list with objects of different types in it.
- dralley 4y agohttps://github.com/ron-rs/ron https://github.com/ron-rs/ron
- magicalhippo 4y ago> what's really lacking in JSON is any support for using custom types to disambiguate polymorphism Unless I misunderstood you, you can use tagged unions[1] for this so not sure JSON needs any change there. Slightly more verbose but shouldn't be an issue in practice. [1]: https://en.wikipedia.org/wiki/Tagged_union https://en.wikipedia.org/wiki/Tagged_union
- breakfastduck 4y agoI unironically have a soft spot for xpath to query a document. The JSON equivalents just dont hit the same spot.
- taeric 4y agoI just introduced jsonpath and jmespath at work. You'd think I was showing dark magic. :)
- calvinmorrison 4y agoRemote Schemas yeah, but have you seen json objects with remote links in them with more objects?
- wombatpm 4y agoXML is like violence. If it is not solving your problem, you need to use more