XML 代码:
XSLT 代码:
<?xml version="1.0" encoding="ISO-8859-1"?> <persons> <person name="Tarzan" id="050676"/> <person name="Donald" id="070754"/> <person name="Dolly" id="231256"/> </persons>
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:key name="preg" match="person" use="@id"/> <xsl:template match="/"> <html> <body> <xsl:for-each select="key('preg','050676')"> <p> Id: <xsl:value-of select="@id"/><br/> Name: <xsl:value-of select="@name"/> </p> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
输出结果:
runoops.com
- 在线实例