如果查询返回此XML
<hudson>
<job>
<displayName>test1</displayName>
<url>https://something/test1</url>
<lastBuild>
<building>true</building>
<builtOn>server1</builtOn>
</lastBuild>
</job>
<job>
<displayName>test2</displayName>
<url>https://something/test2</url>
<lastBuild>
<building>false</building>
<builtOn>server1</builtOn>
</lastBuild>
</job>
<job>
<displayName>test3</displayName>
<url>https://something/test3
</url>
<lastBuild>
<building>true</building>
<builtOn>server2</builtOn>
</lastBuild>
</job>
<job>
<displayName>test4</displayName>
<url>https://something/test4</url>
</job>
<job>
<displayName>test5</displayName>
<url>https://something/test5</url>
</job>
</hudson>
如何使用xpath进一步过滤以仅获取标记building
为真的作业,并排除标记lastBuild
不存在的作业?
对于我使用的第一个选项
&xpath=/hudson/job/lastBuild[contains(building,'true')]
但不确定如何摆脱那些没有标签lastBuild
...
答案 0 :(得分:1)
对于您显示的XML,此XPath,
/hudson/job[lastBuild/building = 'true']
将选择job
元素,lastBuild
为building
的{{1}}元素:
true