How important is it to learn XML when JSON is able to do almost all that I need? Having said that, I use JSON mainly for AJAX requests and obtaining data from various APIs. I am a total newbie to web development and the reason I am asking this is that I want to know whether I should go ahead and buy a book on XML or whether I can just give it a pass.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
You'll need to learn XML to get anywhere in the web world. It's what drives of lot of B2B communications and there are many standard XML formats describing important.
Just restricting yourself to JSON is hugely self-limiting. Yeah, you'll be chucking AJAX calls around but what happens when you need to communicate with a GeoServer? It'll be adhering to GIS standards and will be spurting out XML in WCS (Web Capabilities Service), WMS (Web Map Service) and WFS (Web Feature Service) formats among others. If you don't know how to handle XML, you'll have some trouble with that.
Of course, any marshaller (domain object to text format) worth its salt will be able to convert their objects to and from XML/JSON/YAML so you could make the argument that so long as you can hide behind the marshaller you only have to deal with the domain objects. Web services provide WSDL exactly for this purpose. But sooner or later you'll need to read and understand the contents of your requests and responses and that will certainly require an understanding of XML.
And let's not forget good ol' XHTML the old web standard for HTML pages. It's XML.
So, in short, learn XML - and keep JSON wherever you can 'cos it's lovely.
XML definitely outshines JSON for markup (which is, after all, hinted at in the name).
I wouldn't like to see a random XHTML page converted into JSON format. It would be horrible. OpenOffice and the latest editions of Microsoft Office all use compressed XML as their format of choice.
As a general rule: Markup goes in XML; structured data goes in JSON.
That's when you're outputting data and have full control yourself over the format. If you're outputting data according to industry standards, or consuming other people's data, you may need to use XML even in places where JSON would seem more appropriate. That's because XML is longer established and has been used in many standards.