jsbisht
jsbisht

Reputation: 9659

Is it better to use XML instead of HTML to create webpages?

I want to create a website. After seach for all the possible technologies i can use for my webpage, i found out that XML is best way to store data. The idea is to keep data and representation seperately. i would use style sheets to give presentation for the webpages.

So is it better to use XML instead of HTML for storing webpages. If yes, then which tool can i use to create my webpages.

Upvotes: 4

Views: 8722

Answers (6)

David Parks
David Parks

Reputation: 32081

XHTML is basically HTML that is requires a verifiable XML structure. The point being that you are less likely to implement minor mistakes which might be interpreted differently on different platforms. And you can verify your work follows established browser standards with more ease (you're alerted right away to a problem, whereas HTML will often mistakes to silently fall through the cracks).

Here is some more information about XHTML:

http://www.w3schools.com/xhtml/xhtml_intro.asp

http://www.w3schools.com/xhtml/xhtml_html.asp

Many well known websites use XHTML, however many more websites just use plain old HTML. I tend to use plain old HTML, because it works and I throw caution to the wind. If you're learning first time and you don't mind a few extra hours to do it the "right" way, pick up XHTML.

However I will add to this discussion, your question was about storing data, you should differentiate in your terminology between "storing data" and presenting a view. A well designed website will generally store data in some datastore (a database usually) and present the data in some form (be it XML, or more commonly, a collection of objects), and use a view technology to present that information in what could be one of many different forms. One could be XHTML, but you might create another view of the same data for mobile users, and another view of the same data for a B to B backend application, or a webservice, or XML for an iPhone app... the list goes on.

The point being that if you design your application well in the beginning (here's a new term for you), using a Model-View-Controller approach it will be easy to create different "views" of the same backend data, regardless of how that data is stored. This means that you separate the code that creates the ultimate presentation HTML/XHTML, webservice, etc, from the data that is used to create that view. In the Java world the Spring-MVC framework is a good example of this.

I hope that helps get you going in the right direction.

Upvotes: 2

Andrew Barber
Andrew Barber

Reputation: 40150

XML with XSLT or other styling methods can be used to create web pages. But I think someone would need a truly compelling reason to want to do so. Basically, that compelling reason could only be:

We already have all of the data ready, exactly as we will need it for the web site, ready right now to use, and just need to create a couple XSLT's and we're set.

I think that applies to almost no one. And even if it did apply, it would likely still be better to generate most of the site using some other technologies, and merely import the XML in and display it within some other framework.

Upvotes: 2

erjiang
erjiang

Reputation: 45727

You're better off storing data separately, like in a database, and then having the web application retrieve and format the data as HTML (or anything else).

If you're not using a web application and are just hand-coding some pages, XML + XSLT can work, but it's a pain that might not bring any real benefits.

XML + XSL can be great if you want to simultaneously provide a data service and a web site at the same time. For a good example, look at much of Blizzard's pages.

See this similar question from a while ago: What is preventing widespread use of XSLT for webpages?

Upvotes: 4

Brad
Brad

Reputation: 163458

If you mean you want to output XML and let a browser figure out your XSL... absolutely do not do this.

Use XHTML. It is HTML that conforms to XML specifications as defined by the various DTDs.

Also, you should know that it often isn't practical to totally separate your data (page elements) from your representation. I'm sure 100 people will disagree with me on this, but you should focus your efforts more on building pages that are compatible, accessible, and maintainable (as said by @SHiNKiROU) rather than a perfect separation between page elements and layout/CSS.

Usually, those goals line up with content separation from design, but sometimes they do not.

Upvotes: 9

Ming-Tang
Ming-Tang

Reputation: 17651

For accessibility, compatibility and maintainability, I will say no. HTML is the standard for making webpages, and mobile phone and terminal browsers render HTML. Also, XML is strict in syntax. If there is a syntax error, the whole page breaks.

For a better solution, put XML data in your server and use PHP or ASP to process and present the data as HTML. Even better, use relational databases to store data instead.

Upvotes: 1

generalhenry
generalhenry

Reputation: 17319

use both: xhtml

Upvotes: 2

Related Questions