JSON vs. XML: What Should You Use?
From the start, JSON is already has a leg up on XML for one reason: it’s faster. To read XML you need to parse it, read the nodes, attributes, and child nodes in the XML document, and then use the data that you’ve found.
Another good reason to use XML is that it’s widely available. Lots of websites offer APIs to get at their public (and sometimes private) data, and I usually find the returned format of these APIs are often either XML or JSON. However since XML has been around longer than JSON, there is simply more XML out there.
Sometimes you might find yourself in a situation where you don’t have JSON as an option. So do you submit to the API gods and slow down your site and just use the XML? Why do that when you can write the API yourself! This is where some server side skills come in handy. It’s super easy to load an XML document via PHP and print out the data in whatever format you need it to be in.
So in conclusion, you should be using JSON every chance you get.
[…] This post was mentioned on Twitter by Vladimir Statsenko, Think2Loud. Think2Loud said: New post : JSON vs XML, What Should You Use? http://bit.ly/6jV6dv […]
could you be so kind to provide some performance tests between JSON and XML ? you say XML is slower… is it possible to see some figures? :) good stuff, thanks.