当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > <xsl:value-of>
The <xsl:value-of> element is used to extract the value of a selected node.
<xsl:value-of>元素是用于选取一个已选中的节点值的。
The <xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformation:
<xsl:value-of>元素可以用来选取一个XML元素的值,并把它添加到转换后的输出流里:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:template match="/"> </xsl:stylesheet> |
Note: The value of the select attribute is an XPath expression. An XPath expression works like navigating a file system; where a forward slash (/) selects subdirectories.
注意: 选择(select)属性值是一个XPath表达式。XPath表达式的作用,如:对文件系统进行导航,通过在前面添加斜杠 “/” 来选择子目录。
The result of the transformation above will look like this:
上述代码的转换结果如下:
Title | Artist |
---|---|
Empire Burlesque | Bob Dylan |
View the XML file, View the XSL file, and View the result
XML 文件, XSL 文件, 以及 最终结果
The result from this example was also a little disappointing, because only one line of data was copied from the XML document to the output.
通过这个例子得到的结果同样让人有点失望,因为只有一行数据从XML文件中复制到结果。
In the next chapter you will learn how to use the <xsl:for-each> element to loop through the XML elements, and display all of the records.
在下一章中,你将学会如何使用<xsl:for-each>元素来循环操作XML元素,并显示所有记录。