Hacker News new | ask | show | jobs
by reenorap 23 days ago
I’ve hated XML since 2004. The worst part about it is the tags vs attributes fights. They both do the same thing and the only difference is preference. Having two ways of doing the same thing invite and incite religious positions and cause unnecessary fighting. There should be one, opinionated way of doing things so you avoid confusion.
2 comments

> The worst part about it is the tags vs attributes fights. They both do the same thing and the only difference is preference.

They're not the same thing. If you look at it as the extensible markup language for documents that it is, "tags" (i.e. inner content) would be visible and "attributes" would not. If your XML document was processed by an application to convert to another type of document (PDF, etc.), and it didn't recognize a particular tag, it would be sensible for attributes to disappear, but inner content ("tags") to remain.

It's only seems like a preference thing if you look at XML as a structured data format like JSON is.

In data structure terms, attributes do allow nodes to be decorated with additional information without forcing any change on existing parsers. In JSON, this would require swapping, eg. "str" -> {"value": "str", "attrib1": "..."}.
> If you look at it as the extensible markup language for documents that it is, "tags" (i.e. inner content) would be visible and "attributes" would not.

  <input type="text" value="Is this text visible?" />
yeah it's not a good design to have tags have two sets of children: a Set of key-value children and then a List of tree object children.