我有以下 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/