Possible Duplicate:
How to use XPath function in a XPathExpression instance programatically?
I'm trying to find all of the rows of a nested table that contain an image with an id that ends with '_imgProductImage'.
I'm using the following query:
"//tr[/td/a/img[ends-with(@id,'_imgProductImage')]"
I'm getting the error: xmlXPathCompOpEval: function ends-with not found
My google searches i believe say this should be a valid query/function. What's the actual function i'm looking for if it's not "ends-with"?
from How to use XPath function in a XPathExpression instance programatically?
One can easily construct an XPath 1.0 expression, the evaluation of which produces the same result as the function
ends-with()
:
$str2 = substring($str1, string-length($str1)- string-length($str2) +1)
produces the same boolean result (
true()
orfalse()
) as:
ends-with($str1, $str2)
so for your example, the following xpath should work:
//tr[/td/a/img['_imgProductImage' = substring(@id, string-length(@id) - 15)]
you will probably want to add a comment that this is a xpath 1.0 reformulation of ends-with()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With