Crimson King wrote:Is there a situation where you'd pick XML over JSON to serialize your data?
Good question. In general, no (unless you're saving data to an existing format that uses XML, e.g. bookmarks, or ASX playlists). There are some edge cases. XML has a bunch of features that are rarely used (or useful), which typically just add to reasons for not using it. Sometimes such features are
useful for what you're doing, and then you might consider using XML. For example, XML supports schema validation -- a document can contain a link to a DTD or XSD schema that can be used to make sure that the document contains a valid structure; the ability to query large documents using XPath can also come in handy; namespaces, while generally a nuisance, may be useful in some environments (where element name clashes are likely). All of these aren't that common, and if you find you really need them, then you're probably doing something wrong (e.g. if you find you rely on XPath a lot to navigate your data, you should probably be storing it in a proper database).
Crimson King wrote:only one that says XML beats JSON when the number of elements to encode surpasses 5000 (no benchmarks found whatsoever)
Hm, well that would largely depend on the specific parsers used. XML does have a streaming SAX parser as well as DOM, which would make it more suitable for dealing with large documents (as you don't have to build the whole structure in memory). I am not aware of streaming JSON parsers, though in principle, there is not reason why there couldn't be one. But then, if you have 5000 elements in a single text file, something is probably wrong (maybe use a DB, or if it contains settings or configuration, break it up into several files). Large text files are usually hard to work with regardless of format. And XML is a verbose format, so if you do have a lot of data, XML is not going to be an efficient way of storing it.
Crimson King wrote:And also wanted to add one more to the list: YAML
Ah yes, forgot about that one. Thanks for pointing it out. Haven't played much with it either, but it seems to be a sort of half-way house between XML and JSON in terms of complexity and seems to mostly be used for configuration files and such.