The Open Source Swiss Army Knife

/xml/
/xml/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /xml 
Permalink: f4each.htm
Title: add
article options : please login   |  print view

this documnet is a working example of an xml to html transformed with an xsl stylesheet. the ie5.0+ did the transformation.

the xml file:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="foreach.xsl"?>
<catalog>
   <cd>
      <title>empire burlesque</title>
      <artist>bob dylan</artist>
      <country>usa</country>
      <company>columbia</company>
      <price>10.90</price>
      <year>1985</year>
   </cd>
</catalog>

the xsl file:

<?xml version='1.0'?>
                 <xsl:stylesheet xmlns:xsl="http://www.w3.org/tr/wd-xsl">
                 <xsl:template match="/">
                   <html>
                   <body>
                     <table border="2" bgcolor="yellow">
                       <tr>
                         <th>title</th>
                         <th>artist</th>
                       </tr>
                       <xsl:for-each select="catalog/cd">
                       <tr>
                         <td><xsl:value-of select="title"/></td>
                         <td><xsl:value-of select="artist"/></td>
                       </tr>
                       </xsl:for-each>
                     </table>
                   </body>
                   </html>
                 </xsl:template>
                 </xsl:stylesheet>



try it out

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top