xslt:与元素关联的文本值 [英] xslt: value of text associated with element

查看:28
本文介绍了xslt:与元素关联的文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个包含以下内容的 XML 文件

If I have an XML file that includes

<param name="foo" value="5000" >foo is a way of making pasta sauce</param>
<param name="bar" value="3000" >bar is controlling the beer taps</param>

而我想用XSLT将其处理成HTML文件,以name和value属性,以文本为描述,如何获取XML节点文本?

and I want to use XSLT to process this into an HTML file, with the name and value attributes and the text as a description, how can I get the XML node text?

<xsl:for-each select="param">
   <tr>
      <td><xsl:value-of select="@name"/></td>
      <td><xsl:value-of select="@value"/></td>
      <td><xsl:text> </xsl:text></td>
   </tr>
</xsl:for-each>

上面的 XSLT 片段确实成功地获取了 name 和 value 属性,但它无法获取文本,我想我遗漏了一些明显但我不知道的东西.

The above XSLT fragment does successfully get the name and value attributes, but it fails to get the text, and I think I'm missing something obvious but I don't know what.

推荐答案

试试这个

<xsl:for-each select="param">
   <tr>
      <td><xsl:value-of select="@name"/></td>
      <td><xsl:value-of select="@value"/></td>
      <td><xsl:value-of select="text()"/></td>
   </tr>
</xsl:for-each>

这篇关于xslt:与元素关联的文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆