Reputation: 4003
I'm a little new to xpath and I was wondering if you anyone can help me understand what's wrong with the following xpath query. The server is telling me I have an "invalid predicate"
Here's the xpath:
xpath("div[span[@class='paragraphnumber]/text()='$next_pn']/@id")
I want this to find the @id of the div which contains within it a span element with the @class of "paragraphnumber" and the text which equals the number contained in the variable $next_pn. The div would look something like this:
<div id="pl8ddjkdj"><span class="paragraphnumber">3</span>lor ipsum etc etc</div>
Basically, I'm starting with the number I want to be able to find the unique id of this div.
Thanks for your help.
Upvotes: 0
Views: 77
Reputation: 38173
You have just missed a single quote ('
) after the name of the class paragraphnumber
.
This:
xpath("div[span[@class='paragraphnumber]/text()='$next_pn']/@id")
should be
// v
xpath("div[span[@class='paragraphnumber']/text()='$next_pn']/@id")
Upvotes: 0