Quackit Logo

FREE Hosting!

With every domain name you register with ZappyHost, you get FREE hosting.

$1.99 Domain Names

With every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99.

XSLT <value-of> Element

Print Version

The <xsl:value-of> element allows you to retrieve the value from a node.

When using the <xsl:value-of> element, you use the select attribute to specify which node you want to retrieve data from.

Usage Example

This example is a continuation of the example from the previous lesson. Here, we have added the <xsl:value-of/> element to extract data from the child nodes called "name" and "url".

<xsl:template match="/">
  (other content/HTML markup goes here)
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="tutorial">
  <xsl:value-of select="name"/>
  <xsl:value-of select="url"/>
</xsl:template>

So, let's have another look at our XML document, and see which values will be selected:

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="tutorials.xsl"?>
<tutorials>
<tutorial>
<name>XML Tutorial</name>
<url>http://www.quackit.com/xml/tutorial</url>
</tutorial>
<tutorial>
<name>HTML Tutorial</name>
<url>http://www.quackit.com/html/tutorial</url>
</tutorial>
</tutorials>

And just to refresh your memory, these values will be displayed where we choose to place the XSLT <xsl:apply-templates> element.

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
               
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!