xpath question

uche.ogbuji at gmail.com uche.ogbuji at gmail.com
Sun Jul 2 22:23:24 EDT 2006


bruce wrote:
> is there anyone with XPath expertise here? i'm trying to figure out if
> there's a way to use regex expressions with an xpath query? i've seen
> references to the ability to use regex and xpath/xml, but i'm not sure how
> to do it...
>
> i have a situation where i have something like:
>  /html/table/..../[@class='foo']
>
> is it possible to do soomething like [@class~=/fo/] so i'd match the class
> attribute with fo....
>
> i'm trying to parse HTML/Web docs...

4Suite [1] supports regex in XPath using the EXSLT community standard's
regex module [2].  It would be something like:

[re:match(@class, 'fo.*']

With the re prefix set as required by the EXSLT module.

[1] http://4Suite.org
[2] http://www.exslt.org/regexp/

--
Uche Ogbuji                               Fourthought, Inc.
http://uche.ogbuji.net                    http://fourthought.com
http://copia.ogbuji.net                   http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/




More information about the Python-list mailing list