W3Schools.com

XSLT key() Function


XSLT Function Reference Complete XSLT Function Reference

Definition and Usage

The key() function returns a node-set from the document, using the index specified by an <xsl:key> element.


Syntax

node-set key(string, object)

Parameters

Parameter Description
string Required. Specifies the name of an xsl:key element
object Required. A string to search for

Example 1

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

<xsl:key name="cdlist" match="cd" use="title" />

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('cdlist', 'Empire Burlesque')">
  <p>
  Title: <xsl:value-of select="title" />
  <br />
  Artist: <xsl:value-of select="artist" />
  <br />
  Price: <xsl:value-of select="price" />
  </p>
</xsl:for-each>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

View the XML file, View the XSL file, and View the result.


XSLT Function Reference Complete XSLT Function Reference
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE