Many of you have probably wondered which format is better or which should be used. You might have even participated in a full blown nerd rage war on the matter.
Both formats are good when you want to describe a hierarchical structure.
- XML is a markup language and is good for documents description or text documents with formatting information.
So when should you use each one of them?
- If your front-end is an Apache Flex app or a Starling game then XML is the right choice. Action Script 3 XML parser is really powerful and nicely working.
- XML is great when your data contains styling information like text style or formatting.
- If you need a really really complex data structure with information coming from lots of sources then the XML format together with namespaces is the best choice. This way you’ll also avoid naming clashes.
- XML is slightly more readable from human beings than JSON. If the content will be static and edited by Muggles (not programmers) then go with XML. But if, and only if, you have a bunch of Muggles who are well trained in the art of magic basics, you can also choose JSON.
- If the bandwidth is of high importance for you then the XML with its close/open tags (container tags) will take up unnecessary resources. JSON on the other hand is just a simple key/value pairs which will lead to less traffic.
Both formats have their pros and cons. The choice really depends on the technologies you’ll be using and the specifics of the data. My guess is that in most cases you’ll be working with JSON, but there are still some XML islands here and there.
I, personally, am secretly obsessed with using the XML plus XSLT combo, so rejoice fellow elderly orcs! XML is still alive…ish.