Live data from Hacker News

When XML Beats JSON: UI Layouts

engineering.instawork.com

61–70 of 274 posts

Re: When XML Beats JSON: UI Layouts

#61
post #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.

{ "type": "div", "children": [ "The ", { "type": "a", "attributes": { "href": "https://www.json.org/" }, "children": [ "JSON format" ] }, " was invented by ", { "type": "a", "children": [ "Douglas Crockford" ] } ] }

I think I prefer the XML :-)

Edit: I agree that tagged text is a clear win for XML - for pretty much everything else I'd go for JSON.

Edit2: HN ate my formatting, but probably not a bad thing ;-)

Re: When XML Beats JSON: UI Layouts

#62
post #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/grap…

Side note: You've overdone the character entities a bit more than necessary.

Re: When XML Beats JSON: UI Layouts

#63
post #38

I am not familiar with Xcode: is there an easy way to get the exploded 3D view of DOM in a browser? Maybe a browser extension?

Firefox used to do this, but looks like they haven't for a while. Guess it's been longer than I thought since I used it.

https://developer.mozilla.org/en-US/docs/Tools/3D_View

Re: When XML Beats JSON: UI Layouts

#64
post #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.

So Jupyter Notebooks should be XML instead of JSON. Right ?

Re: When XML Beats JSON: UI Layouts

#65

Earlier quoted context omitted.

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).

Why the hostility? Should we not be open to exploring alternate ideas?

Re: When XML Beats JSON: UI Layouts

#66
post #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.

Amazing. Who would've thought a markup language would be appropriate for the task

Re: When XML Beats JSON: UI Layouts

#67
post #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.

It is ugly:

["div", 0, "The ", ["a", {"href": "https://www.json.org/"}, "JSON format"], " was invented by ", ["em", 0, "Douglas Crockford"], "."]

Re: When XML Beats JSON: UI Layouts

#69
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 power…

> You can't express number or array with XML

Numbers can be expressed, they just have to be parsed on the client. For array, child elements are ordered and form an array naturally.

Re: When XML Beats JSON: UI Layouts

#70
While not really JSON, HyperScript[1] is much easier to grok than XML to me. It allows you to define layouts really naturally using standard JS objects. Mithril[2] specifically implements it really well.

1 - https://github.com/hyperhype/hyperscript

2 - https://mithril.js.org/index.html#dom-elements

Post reply on HN