xslt - 如何在 XPath 表达式中的多个子项上使用 concat() 函数

标签 xslt xpath xpath-1.0

像这样的东西工作正常“concat('a', 'b')”,但我不能它作为现有表达式的一部分工作,即

<div class='xyz'>
    <strong>the</strong>
    <sub> one</sub>
</div>

//div[class='xyz']/concat(/strong/text(), /sub/text())

我希望它返回“那个”

最佳答案

i'd like it to return 'the one'

XPath 1.0中,您必须执行以下操作:

concat(div[@class='xyz']/strong, div[@class='xyz']/sub)

XSLT 1.0中,您可以:

<xsl:template match="/">
    <xsl:for-each select="div[@class='xyz']/*">
        <xsl:value-of select="."/>
    </xsl:for-each>
</xsl:template>

关于xslt - 如何在 XPath 表达式中的多个子项上使用 concat() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32727009/

相关文章:

xslt - 单引号转义 XSLT 1.0 中的动态字符串值

javascript - 如何提取两个节点之间的文本内容

java - 子树上的 xpath 搜索

xml - 如何获取具有最小属性值的节点?

XSLT:我可以全局声明一个变量,然后给它赋值吗

xslt - 字符串序列与空字符串的比较

php - XSLT/Xpath : Selecting a preceding comment

xml - Concat 函数与 XPath 中的字符串

xslt-1.0 - 使用 XPath 选择包含撇号的字符串

python - Selenium 的 XPath 问题