Learn XML, XSLT, XPath with Tutorials & Samples


xsl:value-of
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="/">  

    1. <xsl:value-of select="//book[2]/author"/>    <br/>
    2. <xsl:value-of select="store/book[3]/title"/> <br/>
    3. <xsl:value-of select="store/book/author"/>   <br/>
    4. <xsl:value-of select="/*/*/*[3]"/>           <br/>

    5. <xsl:value-of select="//*[1]/*/*[2]"/>       <br/>
    6. <xsl:value-of select="/*/*/*[1]"/>           <br/>

    7. <xsl:value-of select="*/*/price"/>           <br/>

    8. <xsl:value-of select="name(/*/*/*[3])"/>     <br/>
    9. <xsl:value-of select="/*//title"/>           <br/>

  </xsl:template>

</xsl:stylesheet>


OutPut:

1. Vijay
2. HTML
3. Bill
4. 25.50
5. Bill
6. XML
7. 25.50
8. price
9. XML