Displaying XML into HTML
To transform XML into HTML, you can use CSS, or XSLT. XSLT is the recommended
style sheet language of XML. XSLT stands for "eXtensible Stylesheet Language
Transformations". The below is an example of how to link an XML file to
XSLT file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="gps_template.xsl"?>
<gps>
<item>
<name>TomTom XL 330S 4.3-Inch Touchscreen Traffic-Ready Portable GPS Navigator</name>
<price>$299.95</price>
<link>http://www.selectagps.com/TomTom-XL-330S-4-3-Inch-Touchscreen-Traffic-Ready-Portable-GPS-Navigator-Electronics--d_B0016ORQDI.html</link>
<description>
<![CDATA[An extra-wide touchscreen helps you find your way, worry-free. TomTom
has the most accurate maps and with TomTom Map Share technology you can instantly
modify street names, street direction, and POIs on your own device. The XL 330
is preloaded with millions of points of interest to enhance your traveling experience.
The TomTom XL 330 is traffic-ready, so you can outsmart the traffic, wherever
you go, and go confidently.]]>
</description>
</item>
</gps>
In the example above, the XSLT transformation is done by the browser, when
the browser reads the XML file. Different browsers may produce different result
when transforming XML with XSLT.
Using either CSS or XSLT for transforming XML into HTML is complicated. If
you already know one of scripts, for example, Javascript, ASP, or PHP, you don't
have to use CSS or XSLT for transforming XML into HTML. In the following chapters,
we will discuss how to do it.
|