user898465
user898465

Reputation: 944

select all nodes if another element has a certain value

If I have the xml document

<A>
  <B>TEXT</B>
  <C>
     <D>1</D>
     <E>2</E>
  </C>
  <C>
     <D>3</D>
     <E>4</E>
  </C>
</A>

Is it possible in a single xpath to get all values of A/C/D if the value of <B> is TEXT and select nothing if it is any other value?

Upvotes: 1

Views: 38

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167436

The path /A[B = 'TEXT']/C/D selects the two D elements in your sample.

Upvotes: 3

Related Questions