xpath select parent based on child value

跟風遠走 提交于 2020-01-24 15:11:20

问题


I am looking to select every event where the status is "Live"

I am using this in Drupal's XPath XML parser and have the Context base query and xpath queries fields.

(Context=This is the base query, all other queries will run in this context.)

I current have:

Context: ./event[./status = 'Live']

title: title

Description: description

<events>

<event>
 <title>Number 1</title>
 <status>Draft</status>
 <description></description>
</event>

<event>
 <title>Number 1</title>
 <status>Live</status>
 <description></description>
</event>

</events>

回答1:


I don't know drupal but this XPath worked fine for me in XPath tester :

./events/event[ status = 'Live']


来源:https://stackoverflow.com/questions/24898248/xpath-select-parent-based-on-child-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!