Learn XML, XSLT, XPath with Tutorials & Samples


123Title
XML XSL

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myFile.xslt"?>

<store>

  <book id="1">
    <title>XML</title>
    <author>Bill</author>
    <price>25.50</price>
  </book>

  <book id="2">
    <title>XSL</title>
    <author>Vijay</author>
    <price>75.60</price>
  </book>

  <book id="3">
    <title>HTML</title>
    <author>Kris</author>
    <price>50.40</price>
  </book>

</store>

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>

 <xsl:template match="/">
   <xsl:for-each select="//*">

     <xsl:value-of select="position()"/>   .
     <xsl:value-of select="name()"/>       ,
     <xsl:value-of select="text()"/>      <br/>

   </xsl:for-each>
 </xsl:template>

</xsl:stylesheet>

OutPut:

1. store,
2. book,
3. title, XML
4. author, Bill
5. price, 25.50
6. book,
7. title, XSL
8. author, Vijay
9. price, 75.60
10. book,
11. title, HTML
12. author, Kris
13. price, 50.40