?
This document uses PHP Chinese website manual Release
key() 函數(shù)通過使用由 <xsl:key> 元素規(guī)定的索引號,從文檔中返回節(jié)點集。
node-set key(string, object)
參數(shù) | 描述 |
---|---|
string | 必需。規(guī)定 xsl:key 元素的名稱。 |
object | 必需。要搜索的字符串。 |
<?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>