What are the demerits of using XML over HTML?

1k Views Asked by At

I was wondering what are the demerits of using XML over HTML or XHTML. I mean, both can be styled using CSS and scripted via JavaScript. Also idea of using XML over HTML sounds much powerful for the developer, since the developer has much much more control over his webpage. Also, without the pre-styled elements of HTML, the XML webpage would be much more cross-browser compatible.

Also, is there a reason that besides of XML being so much more advantageous over HTML, its not such a widespread practice?

PS: I'm a web designer and I have used HTML in all of my project so far for presentation of data. And unless I find a good reason for not doing so, I am thinking of using XML for my next project as I want more control over the data and its presentation.

2

There are 2 best solutions below

15
On

There is one standard difference between XML and HTML; HTML is used for presentation while XML is used for data representation.

EDIT: I had wrongly written HTML to be a subset of XML in my original answer. Thanks to @BoltClock for correcting me.

HTML (along with CSS and JS) is a markup used for presentation. All web pages have to have a valid HTML markup to be correctly rendered on the page. HTML has it's own valid tags and developers have to use only these markup tags for presentation based on a valid HTML DTD. HTML standards are set by the W3C and most browser vendors and developers are supposed to conform to these standards when working on HTML.

XML is mainly used for data representation and as such XML files are used for storing data. This is just verbose storing of data. XML has it's own way of styling and presentation using XSLT however this does not qualify it as the candidate for web page markup.

Most browsers allow use of custom markup tags within HTML which gracefully accept them and allow them to be styled (but still it's not XML).

Then why give XML it's own way of styling? XML data in the wild quickly gets verbose for large data chunks. Mainly to make it more presentable for human readability XSLT is used (as demonstrated in the example link you provided).

0
On

HTML has an agreed upon set of semantics that different user agents can handle in appropriate ways (a search engine can give weight to headings, a screen reader can change voice for <em>, any ua can render forms and links, etc) that Your Invented XML Application wouldn't have.