[Greasemonkey] Pattern matching on an attribute?
Philip Friedman - Auto Europe
philip at autoeurope.com
Thu Apr 20 08:55:57 EDT 2006
Do you expect the asterisk in foo* to act as a wild card? The Xpath =
operator does not do that. In base Xpath there are no regular expressions.
Try the starts-with or another Xpath function.
document.evaluate('//img[starts-with(@src,"foo")]', document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null );
--
Regards, Phil Friedman - Auto Europe
|-----Original Message-----
|From: greasemonkey-bounces at mozdev.org
|[mailto:greasemonkey-bounces at mozdev.org] On Behalf Of Jonathan Buchanan
|Sent: Wednesday, April 19, 2006 5:27 PM
|To: greasemonkey at mozdev.org
|Subject: Re: [Greasemonkey] Pattern matching on an attribute?
|
|Sean LeBlanc wrote:
|> I'm trying to figure out how I might pattern match on an attribute.
|>
|> Something like:
|>
|> document.evaluate('//img[@src="foo*"]'),
|> document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
|> null );
|>
|> Doesn't seem to work. Is there any way to do this without
|getting all
|> that match img and then cycling over those?
|>
|> Thanks,
|
|Does this do what you want?
|
|//img[starts-with(@src,'foo')]
|
|Reference:
|http://www.w3.org/TR/xpath#section-String-Functions
|_______________________________________________
|Greasemonkey mailing list
|Greasemonkey at mozdev.org
|http://mozdev.org/mailman/listinfo/greasemonkey
|
More information about the Greasemonkey
mailing list