9 ms·
I always use the same example as why I dislike XML so much <a> <b>hi</b> </a> is not the same as <a><b>hi</b></a> But Erik Naggum makes
by wendroid 16y ago
I always use the same example as why I dislike XML so much
<a>
<b>hi</b>
</a>
is not the same as
<a><b>hi</b></a>
But Erik Naggum makes the argument against XML so much more fun
http://harmful.cat-v.org/software/xml/s-exp_vs_XML http://harmful.cat-v.org/software/xml/s-exp_vs_XML
- arethuza 16y agoIn what contexts would those two snippets of XML be treated differently? (Not that I am jumping in to defend XML I'm just curious).
- eli 16y agoIf you wrote code to crawl the tree generated from that XML, you'd have text nodes (of whitespace) in one, but not the other.
- arethuza 16y agoThat's what I thought - I don't think I've ever seen an application that would bother with that difference.
- DrJokepu 16y agoYou're using that application right now - XHTML takes the difference into consideration. Consider the <pre /> tag: <pre><b>Hello!</b></pre> is rendered differently from <pre> <b>Hello!</b> </pre>
- arethuza 16y agoGood point! :-)
- Khaki 16y agoThe difference is a big deal to applications that use XML as a markup language (marking up documents and text), as it was designed to do originally.
- elblanco 16y agoHow are those two examples different? Every XML system I've used would see those as the same. I, however, really enjoyed this line from the link. "I once believed that it would be very beneficial for our long-term information needs to adorn the text with as much meta-information as possible. I still believe that the world would be far better off if it had evolved standardized syntactic notations for time, location, proper names, language, etc, and that even prose text would be written in such a way that precision in these matters would not be sacrificed, but most people are so obsessively concerned with their immediate personal needs that anything that could be beneficial on a much larger scale have no chance of surviving." This wonderfully, succinctly explains why efforts like the semantic web are doomed to failure.
- DrJokepu 16y agoTechnically, they are different. In the first example, there's whitespace between <a> and <b> as well </b> and </a>. Most applications ignore whitespace but they're not required to - whitespace is not ignored in XML.
- jpr 16y agoI just died a little inside. Knowing that there are people out there that would inflict this kind of nonsense as a standard for others to use makes one really lose faith in humanity.
- prodigal_erik 16y agoThat's the only way to distinguish an <strong>emphasized</strong> word from an<strong>emphasized</strong>word
- scott_s 16y agoWhich makes perfect sense for documents. So why do we use a markup language suitable for documents for general data? Whitespace matters in a document, but does not matter for data. (I'm not accusing you, I'm actually curious if you know the answer. I've never had to deal with XML.)
- deleted 16y ago[deleted]
- bsaunder 16y agoI've become a JSON and YAML fan as I think they have higher signal to noise ratios (they each have their own issues with white space though). JSON: {"a":{"b":"hi"}} YAML: --- a: b: hi
- jrockway 16y agoYou're complaining that standard parsers give you extra information about the document being parsed? Another thing that might annoy you: even though comments are "ignored", many XML parsers generate comment nodes in the DOM. This allows you to produce an output document that is exactly equivalent to the input document. If a node doesn't mean anything to your application, ignore it. If you're an XHTML parser, the whitespace is significant, so you need to handle it. If you're a FooML parser, the whitespace is insignificant, so just ignore it. If you hate XML, this is not a particularly good justification.