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.

  • 2
    Given that you'll encounter XML on a rather consistent basis, I'd go ahead and get the book.
    – user131
    Commented Nov 11, 2010 at 7:59
  • 11
    Just read the standard. I've never found XML challenging to learn/understand, just tedious.
    – snakehiss
    Commented Nov 12, 2010 at 9:54
  • I never understood that either- what is so difficult about understanding XML? 99.9% of XML out there is just used as a container for data- it's simple text files people, not anything complicated! Commented Apr 16, 2012 at 18:25
  • everyone should us CSV... Commented Apr 16, 2012 at 19:25
  • 1
    @KeithPalmer: and still there is a high amount of mistakes to be found all around the web. From wrong encoding declaration, to missing escapes for characters that need them to simply using a XML file as one huger CDATA container. And don't get me started about how to misues namespaces. Commented Nov 12, 2012 at 9:26

2 Answers 2


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.

  • 2
    Thanks a lot Gary!XML looks so bloated and really scary to dive in though, but going by what you said, seems like I will have to learn it......!
    – Rasmus
    Commented Nov 11, 2010 at 10:37
  • @Alice Start off slow. Think of it as repetitive HTML. Then allow for case sensitivity. Then consider how different data types (e.g. int, string, date) could be represented and tagged inside those elements or attributes. Then make that data type representation a bit more formal (XSD) and you're about as far as you'll need to go. This tutorial should help: devguru.com/features/tutorials/xml/beginning_xml.html
    – Gary
    Commented Nov 11, 2010 at 10:52
  • 1
    I don't know what language / framework / platform you use, but whichever it is, I'm sure you'll find that it has standard libraries for parsing and generating XML, you shouldn't find yourself interpreting pointy brackets manually. Commented Nov 12, 2010 at 0:56
  • 5
    +1, though for what it's worth, XHTML isn't really all that new and seems to have moved to the backseat with HTML 5. Commented Dec 29, 2010 at 20:53
  • 1
    Maybe. My point was more that the W3C seems like their thinking on XHTML has changed a little in the past few years. It's still there and supported, but it's no longer like you're some kind of IE-loving table-layout-using script kiddie if you use plain HTML instead of XML. It's kinda tangential to your answer anyway though, sorry about that. Commented Dec 29, 2010 at 21:09

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.

  • +1, especially for noting the difference between markup and structured data. Commented Feb 15, 2013 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.