0

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.

Peeyush Kushwaha
  • 3,453
  • 8
  • 35
  • 69

2 Answers2

1

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.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

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

Tanzeel Kazi
  • 3,797
  • 1
  • 17
  • 22
  • XML also is used, and can be used to *present* data – Peeyush Kushwaha Jan 03 '13 at 10:51
  • @PeeyushKushwaha: Tanzeel Kazi is right! Xml can be used for presentation only if it is associated with Xsl transformation, which ultimately renders Html. – Steve B Jan 03 '13 at 10:52
  • @PeeyushKushwaha You are talking about XSLT which on my opinion does not count as developing a web page. – Tanzeel Kazi Jan 03 '13 at 10:53
  • XML can be combined with CSS and used to present data. See these articles: http://www.quackit.com/xml/tutorial/xml_css.cfm , http://webdesign.about.com/od/xml/a/aa110600a.htm – Peeyush Kushwaha Jan 03 '13 at 10:54
  • @PeeyushKushwaha Please give me an example of a _web page_ with this. Have you ever heard of _DocTypes_ and why web developers struggle for making HTML pages cross-browser compatible. Before down-voting please consider understanding the response. – Tanzeel Kazi Jan 03 '13 at 10:55
  • I did not down-vote the answer – Peeyush Kushwaha Jan 03 '13 at 10:56
  • @PeeyushKushwaha Okay. Peace! – Tanzeel Kazi Jan 03 '13 at 10:57
  • And my query is that only, since XML *can* be used instead of HTML, and it *can* be combined with CSS, why is it not used? – Peeyush Kushwaha Jan 03 '13 at 10:58
  • @PeeyushKushwaha I'll update my answer with a more helpful response. – Tanzeel Kazi Jan 03 '13 at 11:01
  • 2
    This answer is full of nonsense. HTML was never intended for pure presentation of data, and HTML has no relation to XML whatsoever. They just happen to look like each other. – BoltClock Jan 03 '13 at 11:14
  • @BoltClock Did I say they have a relation other than it being a subset? You are right they are not used just for presentation of _data_ but it is used for _presentation_. Please correct me where I am wrong. I am open to constructive criticism. – Tanzeel Kazi Jan 03 '13 at 11:19
  • 1
    They have **no** relation at all. One is not a subset of the other just because they happen to look alike. – BoltClock Jan 03 '13 at 11:19
  • @BoltClock Okay. And the rest of the answer? I am sure there must be more points. – Tanzeel Kazi Jan 03 '13 at 11:23
  • @BoltClock So the rest of the answer is not `full of nonsense` anymore? I have acknowledged and incorporated your arguments in the answer. Thanks! – Tanzeel Kazi Jan 03 '13 at 11:37
  • That looks better. I've removed my downvote. – BoltClock Jan 03 '13 at 11:41