Xpath rules - contains() not returning what I'd like -
so far have following xpath set pull word 'gallery' href returns entire url instead of word gallery. explain i'm doing wrong please? you, it's appreciated!
$x("//link[@rel='canonical' , contains(@href,'gallery')]")
your current xpath expression,
$x("//link[@rel='canonical' , contains(@href,'gallery')]")
returns sequence of <link>
elements. depending on way evaluate them, might getting text content.
if want word 'gallery'
, in xpath 2.0 can say
$x("//link[@rel='canonical' , contains(@href,'gallery')]/'gallery'")
which return sequence of strings, 1 'gallery'
each <link>
element fulfills predicate.
or
$x("if (exists(//link[@rel='canonical' , contains(@href,'gallery')])) 'gallery' else null")
which return either 'gallery'
(once), or null.
Comments
Post a Comment