当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT <xsl:value-of> 元素
The <xsl:value-of> element extracts the value of a selected node.
<xsl:value-of> 元素的作用是:提取一个指定节点的值。
The <xsl:value-of> element can be used to select the value of an XML element and add it to the output.
<xsl:value-of>元素的作用是:选择一个XML元素的值并将其添加到输出文档中。
Note: The value of the required select attribute contains an XPath expression. It works like navigating a file system where a forward slash (/) selects subdirectories.
注意:必要的select[选择]属性值包含了一个XPath表达式。它的运行方式如同一个文件操作系统,该系统内通过在前面加上斜杠(/)来选择子目录。
<xsl:value-of select="expression" disable-output-escaping="yes|no"/> |
属性 | 值 | 描述 |
---|---|---|
select | expression | Required. An XPath expression that specifies which node/attribute to extract the value from 必要参数。指定一个XPath表达式,该表达式是用于指明从哪个节点/属性中提取值。 |
disable-output-escaping | yes no | Optional. "yes" indicates that special characters (like "<") should be output as is. "no" indicates that special characters (like "<") should be output as "<". Default is "no" 可选参数。如果设置为"yes",则指定了具体字符(如:“<”)以其本身形式输出;如果设置为"no",则指定了具体字符(如:“<”)必须作为"<"输出。默认为no |
<?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> |
<?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> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> |