Is it better to use XML instead of HTML to create web pages?

I want to create a website. After getting to know all the possible technologies that I can use for my web page, I learned that XML is the best way to store data. The idea is to store data and view separately. I would use style sheets to provide a presentation for web pages.

So itโ€™s better to use XML instead of HTML to store web pages. If so, which tool can I use to create my web pages.

+4
source share
6 answers

If you mean that you want to output XML and let the browser detect your XSL ... absolutely do not.

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

In addition, you should be aware that it is often impractical to completely separate your data (page elements) from your presentation. Iโ€™m sure 100 people will disagree with me about this, but you should focus more on creating compatible, accessible and supported pages (as @SHiNKiROU says), and not on the perfect separation of page elements and layout / CSS.

Typically, these goals are built in accordance with the content section of the design, but sometimes they do not.

+7
source

You are better off storing the data separately, for example, in a database, and then getting the web application and formatting the data as HTML (or something else).

If you are not using a web application and simply manually coding some pages, XML + XSLT may work, but it is a pain that may not bring any real benefits.

XML + XSL can be great if you want to provide both a data service and a website at the same time. For a good example, browse through most of the Blizzard pages.

See this similar question for this: What is stopping the widespread use of XSLT for web pages?

+3
source

use both: xhtml

+2
source

XHTML is basically HTML, which requires a validated XML structure. The fact is that you are less likely to implement minor errors that can be interpreted differently on different platforms. And you can test your work in accordance with established browser standards with greater ease (you immediately warn about a problem, while HTML often makes mistakes to fall through cracks).

Here is 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 other websites use plain old HTML. I tend to use plain old HTML because it works, and I throw caution down the drain. If you are studying for the first time, and you donโ€™t mind for a few extra hours to do it in the โ€œrightโ€ way, get XHTML.

However, I will add to this discussion the issue of data storage, you must distinguish between your terminology โ€œ data storage โ€ and presentation . A well-designed website usually stores data in some kind of data warehouse (usually in a database) and presents the data in some form (be it XML, or more often a set of objects), and uses viewing technology to present this information in that could be one of many different forms. One may be XHTML, but you can create a different view of the same data for mobile users and a different view of the same data for the BB backend application or web service or XML for the iPhone application ... the list goes on.

The fact is that if you developed the application well at the beginning (here you will use a new term), using the Model-View-Controller approach, it will be easy to create different "views" from the same source data, regardless of how this data is stored . This means that you separate the code that creates the final HTML / XHTML presentation, webservice, etc., from the data that is used to create this view. In the Java world, an example is Spring-MVC.

I hope this helps you move in the right direction.

+2
source

For availability, compatibility and maintainability, I will say no . HTML is the standard for creating web pages, and browsers for mobile phones and terminals represent HTML. In addition, XML strictly follows the syntax. If there is a syntax error, the whole page breaks.

For a better solution, put the XML data on your server and use PHP or ASP to process and present the data in HTML format. Better yet, use relational databases to store data.

+1
source

XML using XSLT or other modeling techniques can be used to create web pages. But I think that someone will need a truly compelling reason to want to do this. In principle, this compelling reason can only be:

We already have all the data ready, for sure , because we need it for the website, ready to use it right now , and we just need to create an XSLT pair, and we are set up.

I think this applies to almost everyone. And even if it were applicable, most likely, it would be better to create most of the site using some other technologies, and simply import the XML and display it in some other framework.

+1
source

All Articles