Tres
Tres

Reputation: 571

XPath, return all elements with particular element inside

This is the XML

<?xml version="1.0" encoding="UTF-8"?>

<bookstore>

<book>
  <title lang="eng">Harry Potter</title>
  <price>29.99</price>
  <discount>3%</discount>
</book>

<book>
  <title lang="eng">Learning XML</title>
  <price>39.95</price>
</book>

</bookstore>

I can't figure out the XPath expression which return all the books sold with discount.

Upvotes: 0

Views: 107

Answers (1)

choroba
choroba

Reputation: 242383

You want a book anywhere that has a discount:

//book[discount]

Upvotes: 1

Related Questions