displaying XML with XSL

Source: Internet
Author: User
Tags format html page version xsl
xml| Display

You can use XSL to add display information to an XML document.

displaying XML with XSL

XSL is the XML preferred Format table language. XSL (extensible Format Table language) is much more complex than CSS. One way to use XSL is to convert the XML to HTML before it is displayed by the browser, as in the following example:

Click here to view the original XML file.

Click here to view the same file formatted with the XSL format table.

Click here to view the XSL format table.

The abbreviated version of this file is shown below. Note the XSL reference in the second row:


< XML version= "1.0"?>
< Xml:stylesheet type= "text/xsl" href= "simple.xsl"?>
< breakfast-menu>
< food>
< Name>belgian waffles</name>
< price>$5.95</price>
< description>
Two of our famous Belgian waffles
</description>
< calories>650</calories>
</food>
</breakfast-menu>



For more information about XSL, you can access the W3Schools ' xsl School.

XML in the data island

With Iternet Explorer 5.0, XML can be placed in an HTML page embedded in the data island.



embedding XML into HTML

Embed XML data in HTML with an informal < xml> tag. You can embed XML data directly into an HTML page, like this:



< XML id= "NOTE" >
< note>
< to>tove</to>
< from>jani</from>
< heading>reminder< Body>don ' t forget me this weekend!</body>
</note>
</xml>



Or embed a separate XML file:



< XML id= "note" src= "Note.xml" >
</xml>



Note the < xml> tag is an HTML element, not an XML element.



Data binding



You can bundle a data island into an HTML element, such as an HTML table. In the following example, an XML data island with an ID of "Cdcat" is loaded recently from an external XML file. Bind the data island to an HTML table with a data source attribute, and then bundle the XML data into tabular data elements using a range of data field properties.



< html>
< body>


< XML id= "Cdcat" src= "Cd_catalog.xml" ></xml>


< table border= "1" datasrc= "#cdcat" >
< tr>
< td>< span datafld= "artist" ></span></td>
< td>< span datafld= "title" ></span></td>
</tr>
</table>


</body>



If you are running IE 5, you can try it yourself. You can also use IE 5.0 to view external XML files. You can also use this example, demonstration < Thead>, < tbody> and < tfoot>.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.