Hacker News new | ask | show | jobs
by cpunks 5176 days ago
Or... they're designed for different purposes and not even competitors. XML is a markup language:

http://en.wikipedia.org/wiki/Markup_language

It was designed for documents. Try converting an HTML page to JSON. Try something as simple as:

  <h1> Hello World! </h1> 
  <p> The most common introductory program is called 
  <i> Hello, World </i>. </p>
Go on. If you think JSON wins, just do it, and post it below.

The problem was when people started mis-applying XML to send data structures, for RPC, and similar tasks. That's not what it was designed for. JSON is a cross-language way of specifying common data structures, and is very good at doing that.

4 comments

I feel that the real distinction is whether you need to validate the contents against a grammar. The document/data distinction is fairly arbitrary. As far as I know, JSON has no equivalent of the DTD.
Data representation is great in JSON. Actual layout information? Well it's doable but it's not as easy to see. This is why HTML is NOT XML and also why you wouldn't want to convert HTML to JSON.

So I'm not really sure what your point is. Are you trying to say that, because HTML (which is NOT XML) is awkward to represent in JSON, that XML wins?

Yes, JSON is no ML, but YAML is, which is a superset of JSON's semantics/features. You're perfectly right that JSON is not always the right tool for transporting a document, but I still wouldn't regard XML as the best tool for any of those cases.
Please post an example of the HTML above in YAML (or your preferred language) that would be better than SGML or XML.

Sidenote: YAML doesn't consider itself a markup language. See the renaming: http://en.wikipedia.org/wiki/YAML

Well here's my attempt: http://hpaste.org/66897