IamOnStage
IamOnStage

Reputation: 203

xpath select parent based on child value

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>

Upvotes: 2

Views: 10015

Answers (1)

har07
har07

Reputation: 89325

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

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

Upvotes: 3

Related Questions