菜单
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

XML 教程

XML 主页 XML 简介 XML 如何使用 XML 树 XML 语法 XML 元素 XML 属性 XML 命名空间 XML 显示 XML HttpRequest XML 解析器 XML DOM XML XPath XML XSLT XML XQuery XML XLink XML 验证器 XML DTD XML Schema XML 服务器 XML 示例 XML 测验 XML 证书

XML AJAX

AJAX Introduction AJAX XMLHttp AJAX Request AJAX Response AJAX XML File AJAX PHP AJAX ASP AJAX Database AJAX Applications AJAX Examples

XML DOM

DOM Introduction DOM Nodes DOM Accessing DOM Node Info DOM Node List DOM Traversing DOM Navigating DOM Get Values DOM Change Nodes DOM Remove Nodes DOM Replace Nodes DOM Create Nodes DOM Add Nodes DOM Clone Nodes DOM Examples

XPath 教程

XPath Introduction XPath Nodes XPath Syntax XPath Axes XPath Operators XPath Examples

XSLT 教程

XSLT Introduction XSL Languages XSLT Transform XSLT <template> XSLT <value-of> XSLT <for-each> XSLT <sort> XSLT <if> XSLT <choose> XSLT Apply XSLT on the Client XSLT on the Server XSLT Edit XML XSLT Examples

XQuery 教程

XQuery Introduction XQuery Example XQuery FLWOR XQuery HTML XQuery Terms XQuery Syntax XQuery Add XQuery Select XQuery Functions

XML DTD

DTD Introduction DTD Building Blocks DTD Elements DTD Attributes DTD Elements vs Attr DTD Entities DTD Examples

XSD Schema

XSD 简介 XSD 操作指南 XSD <schema> XSD 元素 XSD 属性 XSD 限制 XSD 复杂元素 XSD 空 XSD 仅元素 XSD 仅文本 XSD 混合 XSD 指示符 XSD <any> XSD <anyAttribute> XSD 替换 XSD 示例

XSD Data Types

XSD String XSD Date/Time XSD Numeric XSD Misc XSD Reference

Web Services

XML Services XML WSDL XML SOAP XML RDF XML RSS

参考手册

DOM 节点类型 DOM 节点 DOM NodeList DOM NamedNodeMap DOM Document DOM Element DOM Attribute DOM Text DOM CDATA DOM Comment DOM XMLHttpRequest DOM Parser XSLT 元素 XSLT/XPath 函数

XSLT <xsl:value-of>


❮ XSLT 元素参考

定义和用法

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 元素的值并将其添加到输出中。)


语法

<xsl:value-of select="expression" disable-output-escaping="yes|no" />

属性

Attribute 描述
select expression Required. An XPath expression that specifies which node/attribute to extract the value from. It works like navigating a file system where a forward slash (/) selects subdirectories.(必需。一个 XPath 表达式,用于指定要从中提取值的节点/属性。它的工作方式类似于导航文件系统,其中正斜杠 (/) 选择子目录。)
disable-output-escaping
no
Optional. "yes" indicates that special characters (like "<") should be output as is. "no" indicates that special characters (like "<") should be output as "&lt;". Default is "no"(可选。“yes”表示特殊字符(如“<”)应按原样输出。“no”表示特殊字符(如“<”)应输出为“&lt;”。默认值为“no”)

示例

The example below puts the values from the first title and artist elements and puts it in a table(下面的示例将第一个 title 和 artist 元素的值放入表格中)

示例 1

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

<xsl:template match="/">
  <html>
  <body>
    <h1>Music Collection:</h1>
    <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>
自己动手试一试 »

The example below loops trough each cd element and creates a table row with the values from title and artist for each cd element(下面的示例循环遍历每个 cd 元素,并为每个 cd 元素创建包含 title 和 artist 值的表格行)

示例 2

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

<xsl:template match="/">
  <html>
  <body>
    <h1>Music Collection:</h1>
    <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>
自己动手试一试 »

❮ XSLT 元素参考
×

联系销售

如果您想将 W3Schools 服务用于教育机构、团队或企业,请发送电子邮件给我们
sales@w3schools.com

报告错误

如果您想报告错误,或想提出建议,请发送电子邮件给我们
help@w3schools.com

W3Schools 经过优化,旨在方便学习和培训。示例可能经过简化,以提高阅读和学习体验。教程、参考资料和示例会不断审查,以避免错误,但我们无法保证所有内容的完全正确性。使用 W3Schools 即表示您已阅读并接受我们的使用条款Cookie 和隐私政策

版权所有 1999-2024 Refsnes Data。保留所有权利。W3Schools 由 W3.CSS 提供支持