1.6. Viewing XML

Once you've written an XML document, you will probably want someone to view it. One way to accomplish that is to display the XML on the screen, the way a web page is displayed in a web browser. The XML can either be rendered directly with a stylesheet, or it can be transformed into another markup language (e.g., HTML) that can be formatted more easily. An alternative to screen display is to print the document and read the hard copy. Finally, there are less common but still important "viewing" options such as Braille or audio (synthesized speech) formats.

As we mentioned before, XML has no implicit definitions for style. That means that the XML document alone is usually not enough to generate a formatted result. However, there are a few exceptions:

Hierarchical outline view

Any XML document can be displayed to show its structure and content in an outline view. For example, Internet Explorer Version 5 displays an XML (but not XHTML) document this way if no stylesheet is specified. Figure 1.3 shows a typical outline view.

XHTML

XHTML (a version of HTML that conforms to XML rules) is a markup language with implicit styles for elements. Since HTML appeared before XML and before stylesheets were available, HTML documents are automatically formatted by web browsers with no stylesheet information necessary. It is not uncommon to transform XML documents into XHTML to view them as formatted documents in a browser.

Specialized viewing programs

Some markup languages ...

Get Learning XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.