amethyst_deceiver
amethyst_deceiver

Reputation: 246

jQuery XML parsing: select all nodes containing a certain tag with a certain value

Let's say the XPath is "/bookstore/book[price=35.00]" (from the w3 example).

Here's a fiddle with how far I've got so far.

https://jsfiddle.net/npvgfzwc/

    var name = src.find("bookstore book:has(price:contains('35.00')) title").text();

I can get it to select books with a price containing 35.00, but can't find a way to make it match exactly that. Is there a way to do this?

Upvotes: 0

Views: 247

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82231

You need to use:

var name=src.find("bookstore book price").filter(function(){
  return $(this).text()=="35.00"
}).prev().text();
$('#blah').text(name);

Working Demo

Upvotes: 1

Related Questions