Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What usable alternatives to XML syntax do you know? [closed]

Tags:

syntax

xml

yaml

For me usable means that:

  • it's being used in real-wold
  • it has tools support. (at least some simple editor)
  • it has human readable syntax (no angle brackets please)

Also I want it to be as close to XML as possible, i.e. there must be support for attributes as well as for properties. So, no YAML please. Currently, only one matching language comes to my mind - JSON. Do you know any other alternatives?

like image 422
aku Avatar asked Sep 09 '08 09:09

aku


People also ask

What are alternatives to XML?

YAML, HTML5, JSON, JavaScript, and Python are the most popular alternatives and competitors to XML.

What is the syntax of XML?

All XML documents must have a root elementAll XML documents must contain a single tag pair to define a root element. All other elements must be within this root element. All elements can have sub elements (child elements). Sub elements must be correctly nested within their parent element.

What is better than XML?

JSON is simpler than XML, but XML is more powerful. For common applications, JSON's terse semantics result in code that is easier to follow. For applications with complex requirements surrounding data interchange, such as in enterprise, the powerful features of XML can significantly reduce software risk.


2 Answers

YAML is a 100% superset of JSON, so it doesn't make sense to reject YAML and then consider JSON instead. YAML does everything JSON does, but YAML gives so much more too (like references).

I can't think of anything XML can do that YAML can't, except to validate a document with a DTD, which in my experience has never been worth the overhead. But YAML is so much faster and easier to type and read than XML.

As for attributes or properties, if you think about it, they don't truly "add" anything... it's just a notational shortcut to write something as an attribute of the node instead of putting it in its own child node. But if you like that convenience, you can often emulate it with YAML's inline lists/hashes. Eg:

<!-- XML --> <Director name="Spielberg">     <Movies>         <Movie title="Jaws" year="1975"/>         <Movie title="E.T." year="1982"/>     </Movies> </Director>   # YAML Director:      name: Spielberg     Movies:       - Movie: {title: E.T., year: 1975}       - Movie: {title: Jaws, year: 1982} 

For me, the luxury of not having to write each node tag twice, combined with the freedom from all the angle-bracket litter makes YAML a preferred choice. I also actually like the lack of formal tag attributes, as that always seemed to me like a gray area of XML that needlessly introduced two sets of syntax (both when writing and traversing) for essentially the same concept. YAML does away with that confusion altogether.

like image 151
Ari Avatar answered Oct 07 '22 19:10

Ari


JSON is a very good alternative, and there are tools for it in multiple languages. And it's really easy to use in web clients, as it is native javascript.

like image 45
Staale Avatar answered Oct 07 '22 19:10

Staale