xml - 使用 XPath 从孙子那里获取文本并包含函数

标签 xml xslt xpath xslt-2.0 xpath-2.0

我有以下 XML。

<section level="sect1">
    <title>
      <page num="1150"/>
      <content-style font-style="bold">ORDER 62</content-style>
      <content-style format="smallcaps">Costs</content-style>
    </title>
</section>

这里我想检查 title 中是否有单词 ORDER

我试过了

contains(//section[1]/title[1]/content-style[1]/text(),'ORDER')

但在某些情况下,字符串 ORDER 可能在第二个内容样式中,或者在某些情况下可能在第三个中。

请告诉我找到它的通用方法。

谢谢

最佳答案

你想要

exists(//section[1]/title/content-style[contains(., 'ORDER')])

关于xml - 使用 XPath 从孙子那里获取文本并包含函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32522786/

相关文章:

json - 如何在swift 3中转换xml和json数据

javascript - 未捕获的类型错误 : Failed to execute 'importStylesheet' on 'XSLTProcessor' : parameter 1 is not of type 'Node'

xpath - Selenium IDE - 如何在 Firefox 插件中记录 xpath

sql - 在部分xpath上的Oracle 10.2.0.4.0查询

c# - 节点的内部文本忽略子节点的内部文本

php - 转义 XML 中的符号

java - 某些 Android 设备中的背景颜色错误

html - 我们可以在 XSLT 中使用从数据库表中获取的值吗?

xml - 在 Golang 中解码 XML 数组 : Only Getting The First Element

xml - XSLT:string-length($variable) 给出错误答案