YAML compared to XML

XmlYamlLanguage Comparisons

Xml Problem Overview


I read that after years yaml will be used instead of xml. Please compare the relative advantages and disadvantages of each specification.

Xml Solutions


Solution 1 - Xml

YAML is much less verbose. The signal-to-noise ratio is higher without all the brackets. This makes it subjectively easier to read and edit for many people. On the flip side, it's slightly (only slightly) harder to parse.

The biggest difference, though, is that XML is meant to be a markup language and YAML is really more of a data format. Representing simple, hierarchical data tends to be more gracefully done in YAML, but actual marked-up text is awkward to represent.

EDIT: I'd like to add, for reference, that YAML is essentially (though not historically) a "cleaner" version of JSON ("Javascript Object Notation") that largely eliminates the latter's perceived line noise (brackets and braces). If you can't find a suitable YAML library for a particular project, then JSON is a more widely-supported alternative with many of YAML's advantages.

Solution 2 - Xml

YAML is less verbose than XML; however, YAML is meant just for data and is not technically a markup language (YAML A'int Markup Language).

Solution 3 - Xml

A big plus for xml are the options to validate (opinions in parenthesis):

  • Schematron (extremely powerful)
  • W3C XML Schema (solid)
  • DTD (not so nice (it isn't even xml))
  • XSD (most used)

And options to query data:

  • XPath (in version 2.x even better)
  • XQuery (mostly not of interest anymore)

YAML is probably the easiest to read for humans in most cases.

JSON is quite easy to read and it is the way JavaScript stores data (correct me if wrong). I really like to use JSON when writing my own C style programming languages to parse values.

Solution 4 - Xml

The main advantage that I see is that it is more easily human readable. I also like it a little better than XML because it has the concept of certain data structures (dictionaries and arrays) already built in.

On the flip side, the library support for parsing YAML is nowhere near that of XML, so it is harder to use it to fulfill one of the prime uses of XML. That is inter-application communication.

Solution 5 - Xml

I'm not so convinced about YAML being the future. Whilst I've used it, and it WorksForMe™, I have often seem complaints about the spec. The latest of which is Why I Don't Like YAML.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIguramuView Question on Stackoverflow
Solution 1 - XmlThom SmithView Answer on Stackoverflow
Solution 2 - XmlcakeforcerberusView Answer on Stackoverflow
Solution 3 - XmlRobFView Answer on Stackoverflow
Solution 4 - XmlEBGreenView Answer on Stackoverflow
Solution 5 - XmlDominic MitchellView Answer on Stackoverflow