4 ms·
That's actually why I like XML... the two-dimensional distinction between "metadata" and "content" can be really helpful... if and only if you need it. If you n
by jerf 12y ago
That's actually why I like XML... the two-dimensional distinction between "metadata" and "content" can be really helpful... if and only if you need it. If you need it, then you are dealing with a fundamentally complicated format, and you will actually experience more pain trying to jam it into a single-dimensional format like JSON. By contrast, if the relevant data does not need the two dimensions, which is true of most things, XML is a terrible choice; left adrift without a meaningful way to distinguish between what should be "attribute" and what should be "content", both in theory and in practice all the choices turn out to be terrible.
And, again, if you really need it, the available third dimension provided by XML namespacing is a life-saver when you need it, and incredibly redundant when you don't.
I often dislike the phrase "Use the right tool for the job", because it is vacuous when not tied to some sort of suggestion on how you should determine what the right tool is, so: Match the dimensionality of your data to the dimensionality of the serialization format. The vast bulk of stuff you will encounter day-to-day is one dimensional and fits in JSON or a friend just fine. Use that. A nontrivial quantity of things fits into XML, mostly delimited text; use XML then. Every once in a while you need modularity in your XML format... do not reinvent XML namespaces, use them. (This is mostly for BIG standards, like XMPP or XHTML.) Use neither more nor less than what you need.