【发布时间】:2023-03-25 20:05:01
【问题描述】:
我得到一个 xml 并想通过 XPath Extractor 提取一个元素的值,但是它在 jmeter 中返回“断言失败消息:-1”。
<flag>
<sample>123</sample>
<others>...</others>
<target>a test sample</target>
</flag>
<flag>
<sample>1234</sample>
<others>...</others>
<target>a test sample</target>
</flag>
为了获取元素<target>的文本,其中<sample>为123,尝试了几种方法但都失败了:
//flag[sample='123']/target//sample[.='123']/../target//sample[@value='123']/../target/@value//sample[text()='123']/../target/text()
有没有办法捕获元素<target>的值?
【问题讨论】:
-
第一个是您场景中正确的 XPath...
-
可能是您的示例中的拼写错误,但
<others>...<others>应该是<others>...</others>