What is XML good for and when should i be using it? What is XML good for and when should i be using it? xml xml

What is XML good for and when should i be using it?


JSON is very lightweight which makes it better suited for passing data around to the front end.

XML has descriptive tags that (I personally find) make it easier to read in a raw format.If I wanted to have any sort of settings file that is loaded in from my program, i would have it in an XML file format.

That's my idea of it anyway, but i'm sure there are much more in-depth reasons for choosing one over the other. Of which i am not experienced enough to list :)

However i did find a couple of sites that make some good points.

http://ajaxian.com/archives/json-vs-xml-the-debate (Some good points in the comments)

http://webignition.net/articles/xml-vs-yaml-vs-json-a-study-to-find-answers/


XML is useful for storing heterogeneous tree structures, in situations where general purpose tools can be applied to them and some redundancy is desirable. If you are doing modern web development, there is a good chance you are producing XHTML rather than HTML, and are producing RSS or Atom, so you should already using be it. The most common RDF formats use it.

JSON is a bit easier to work with for data on the web, but hasn't got the same feature set - you can't have attributes in JSON so there is no implicit difference between data and meta-data, and you don't have processing instructions or the ability to create entities for repeated chunks of text. On the other hand, many uses of XMLl don't use those features either. SQL databases have a fixed schema, and do not represent trees well.

Mostly XML is used for interoperability.


One of the advantage of XML over other serialization formats is the number of tools available. The other is the ability to formalize the description of you data (XML Schema).

The availability of tools lets you use XML editors, transformers, visualizers, ... For example, where I work, we have the communication team using an XML editor to edit content and metadata. They are not technical enough to write JSON by hand (or XML), but it is very easy to give them a template with a nice generic frontend to edit the needed documents.

Having a way to describe the format (XSD, DTD, Relax NG, ...) means that you can also automagically validate your documents. It also serves as a pretty good documentation of what is allowed and what is not in your documents.