Live data from Hacker News

When XML Beats JSON: UI Layouts

engineering.instawork.com

41–50 of 274 posts

Re: When XML Beats JSON: UI Layouts

#41
What XML is also very good at is: representing tagged text, what is called "mixed content" in XML terminology.

Just try to write the JSON equivalent of:

    The JSON format was invented by Douglas Crockford.
If your document consists mainly in losely structured text with some annotation, you better use XML.

Re: When XML Beats JSON: UI Layouts

#42

The XML example seemed odd to me as written. In the JSON case, yes there was a prefixed key "$reports", but it told me what the relationship was. Looking at the XML, what does it mean for an Employee to be nested inside another Employee?

Sounds like the list of employees should have been nested in a and not left directly inside the employee.

Re: When XML Beats JSON: UI Layouts

#43

XML is so awesome for UI layouts. I had a thesis that I worked on that was basically a subset of HTML (check the SMIL specification for something similar, albeit a bit more complicated, SMIL used to be a W3C recommendation). It was so easy to understand that every person who was able to use a computer would pick it up quickly. This was not the case for HTML, my guess is because there are a ton of HTML tags and that c…

As someone who has only used html (as in, no other xml-based UI), I'm really curious why it's necessary to even define the tags at all.

Why not allow authors to define their own names? Like

  
    
  
Then internal functionality can be attached to each element via attributes, like how aria roles work.

Re: When XML Beats JSON: UI Layouts

#44
post #16

If XML is better at representing trees, and JSON is a tree, does that mean that XML is better at representing JSON than JSON?

Representing is easy task. You need to parse that representation. And XML here is worse than JSON for typical programming graphs. You can't express number or array with XML. XML Schema helps to add more structure, but JSON does not need that, array and numbers are built-in. And I would say, that XML Schema is too powerful and that's usually not needed by developers. JSON is just a fine medium, simple enough and powerful enough.

But when you deal with inherently hierarchical data, trees, XML is good.

Re: When XML Beats JSON: UI Layouts

#46
Having worked with SOAP/XML extensively at my past job I can say for web services I much prefer REST/JSON. JSON is much easier to work with and key value pairs make it much easier to get what you need. Parsing an XML tree can become a nightmare very quickly.

> However, we’ve created another problem in the form of inconsistency: some user properties are represented as element attributes, others as child elements.

Exactly. I’ve seen XML with element attributes and child elements all over the pace. No rhyme or reason for any of it. It’s especially bad in older systems.

I pushed hard at my last job for the SOA team to build REST/JSON web services. Oracle sold them a product to bridge the gap and they got End Of Life announcements 6 months later! Glad I’m gone.

Re: When XML Beats JSON: UI Layouts

#47
The JSON examples are not even valid, the "$reports" properties on department are written as comma separated lists without enclosing array brackets.

I guess XML might be perfect for when you can't decide between singular and plural and want to leave the problem to others...

Because that's the biggest problem besides charset encoding that JSON helps solving: in JSON, you can be unmistakably clear that a given property is to be interpreted as a list of values, even when the current number is less than two. In XML you can just vaguely communicate that intent with an intermediary "plural element" unless you go full schema.

  
isn't half as clear as

  {"bs":[{}]}
(attributes unrelated to this difference omitted)

Re: When XML Beats JSON: UI Layouts

#49

XML is so awesome for UI layouts. I had a thesis that I worked on that was basically a subset of HTML (check the SMIL specification for something similar, albeit a bit more complicated, SMIL used to be a W3C recommendation). It was so easy to understand that every person who was able to use a computer would pick it up quickly. This was not the case for HTML, my guess is because there are a ton of HTML tags and that c…

As someone who has only used html (as in, no other xml-based UI), I'm really curious why it's necessary to even define the tags at all. Why not allow authors to define their own names? Like Then internal functionality can be attached to each element via attributes, like how aria roles work.

Congrats on re-inventing frontend web development, I heard Facebook's hiring. This is one of the reasons people use frontend frameworks (besides state management).

Re: When XML Beats JSON: UI Layouts

#50

I have yet to read anything that convinces me that XML is good for anything . Just because XML in certain cases is less bad than some other cherry-picked technology, doesn't mean that there aren't other better options. See also Erik Naggum's legendary rant: https://www.schnada.de/grapt/eriknaggum-xmlrant.html

Well, for instance, let's take the HTML code of your comment (which happens to be a valid XML document):

    I have yet to read anything that convinces me that XML is good for anything. Just because XML in certain cases is less bad than some other cherry-picked technology, doesn't mean that there aren't other better options.

See also Erik Naggum's legendary rant: https://www.schnada.de/grapt/eriknaggum-xmlrant.html

What would be the JSON/YAML/TOML equivalent?
Post reply on HN