XSTL value of

To extract the value of a selected node, the <xsl:value-of> element is used in XSLT.

The <xsl:value-of> Element:

The extracted value of an XML element is also added to the output stream of the transformation, by the <xsl:value-of> element.



<?xml version="1.0" encoding="UTF-8"?>
  <book category="Child">
    <title lang="en">ABC</title>
    <author>Author Name</author>
  <book category="IT">
    <title lang="en">XQuery Book</title>
    <author>Author 1</author>
    <author>Author 2</author>

XSLT Code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <h2>List of Books</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th style="text-align:left">Title</th>
      <th style="text-align:left">Price</th>
      <td><xsl:value-of select="bookstore/book/title"/></td>
      <td><xsl:value-of select="bookstore/book/price"/></td>



In the above example, an XPath expression is present in the select attribute, that works like navigating a file system, where a forward slash (/) selects subdirectories.

Please Share