Why are you still using XML?

Node Link

With the advent of JSON, and similar formats such as YAML, some hipster geeks have proclaimed that XML-based grammars no longer have any legitimate use. However, while I use JSON and YAML for many tasks, I still find XML (and some related technologies such as DocBook 5, XPath, RELAX NG, and XSLT) of use. Part of the reason for that is that XML can be used to add markup to a substring of the text, e.g.: like the <a> element:

<p>
I like <a href="http://example.com/" title="site">hyperlinks</a> in my XML.
</p>

I recall that some Lisp fans argued that XML is syntactic sugar for S-expressions. However, I think it is a moot point, because we can encode and decode them both to/from a binary stream of 0s and 1s, JSON, or most other syntaxes. Syntax, while often considered marginal, is nevertheless important, and I don't think I'll enjoy writing text documents completely using S-expressions. I also recall reading about a new programming language that allows mixing and matching both lisp-like code and XML code.


In addition, note that I sometimes use template systems or similar tools to generate XML documents, and documents in other formats.


Now, with respect to HTML 5, the Markdowns and AsciiDoc, while I use them sometimes, they are less structured and more errorprone than many XML grammars, and often are not semantic enough for all my use cases. I can use XSLT, Python, or similar, to convert XML to XHTML5 anyway, whether directly or indirectly. And I often do.

Finally, note that I also use some custom formats such as the one I defined for whitelists of spell-checkers or the so-called Screenplay-Text format.

Relevant links:

  1. The XML FAQ: "Why should I use XML?"

  2. Choice of Document Formats