Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

XSLT <xsl:value-of> elements


May 28, 2021 XSL T


Table of contents


XSLT and lt;xsl: value-of-the-gt; elements

How do I extract a node value from XSLT? Let's take a look at the contents of this section.


The value-of-gt; element is used to extract the value of a selected node.


the element of value-of-the-gt;

The value-of-content element is used to extract the value of an XML element and add the value to the transformed output stream:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td> <xsl:value-of select="catalog/cd/title"/> </td>
<td> <xsl:value-of select="catalog/cd/artist"/> </td>
</tr>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

The instance explanation

Note: In the example above, the value of the select property is an XPath expression. This XPath expression works similarly to locating a file system in which a forward slash (/) can select subdirectors.

The result of the above example is a minor flaw, with only one row of data copied from the XML document to the output. In the next chapter, you'll learn how to loop through the XML elements and display all the records using the .lt;xsl:for-each?gt; element.