Reading StackOverflow and listening the podcasts by Joel Spolsky and Jeff Atwood, I start to believe that many developers hate using XML or at least try to avoid using XML as much as possible for storing or exchanging data.
On the other hand, I enjoy using XML a lot for several reasons:
- XML serialization is implemented in most modern languages and is extremely easy to use,
- Being slower than binary serialization, XML serialization is very useful when it comes to using the same data from several programming languages or where it is intended to be read and understand, even for debugging, by an human (JSON, for example, is more difficult to understand),
- XML supports unicode, and when used properly, there are no problems with different encoding, characters, etc.
- There are plenty of tools which makes it easy to work with XML data. XSLT is an example, making it easy to present and to transform data. XPath is another one, making it easy to search for data,
- XML can be stored in some SQL servers, which enables the scenarios when data which is too complicated to be easily stored in SQL tables must be saved and manipulated; JSON or binary data, for example, cannot be manipulated through SQL directly (except by manipulating strings, which is crazy in most situations),
- XML does not require any applications to be installed. If I want my app to use a database, I must install a database server first. If I want my app to use XML, I don't have to install anything,
- XML is much more explicit and extensible than, for example, Windows Registry or INI files,
- In most cases, there are no CR-LF problems, thanks to the level of abstraction provided by XML.
So, taking in account all the benefits of using XML, why so many developers hate using it? IMHO, the only problem with it is that:
- XML is too verbose and requires much more place than most other forms of data, especially when it comes to Base64 encoding.
Of course, there are many scenarios where XML doesn't fit at all. Storing questions and answers of SO in an XML file on server side will be absolutely wrong. Or, when storing an AVI video or a bunch of JPG images, XML is the worst thing to use.
But what about other scenarios? What are the weaknesses of XML?
To the people who considered that this question is not a real question:
Contrary to questions like a non-closed Significant new inventions in computing since 1980, my question is a very clear question and clearly invites to explain what weaknesses the other people experience when using XML and why they dislike it. It does not invite to discuss, for example, if XML is good or bad. Neither does it require extended discussions; thus, the current answers received so far are short and precise and provide enough info I wanted.
But it is a wiki, since there cannot be an unique good answer to this question.
According to SO, "not a real question" is a question where "It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, or rhetorical and cannot be reasonably answered in its current form."
- What is being asked here: I think the question itself is very clear, and several paragraphs of text above makes it even clearer,
- This question is ambiguous, vague, incomplete: again, there is nothing ambiguous, neither vague nor incomplete,
- or rhetorical: it is not: the answer to my question is not something obvious,
- and cannot be reasonably answered: several people already gave great answers to the question, showing that the question can be answered reasonably.
It also seems quite obvious how to rate the answers and determine the accepted answer. If the answer gives good reasons of what's wrong with XML, there are chances that this answer will be voted up, then accepted.