Gpath <==> XPATH

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Gpath <==> XPATH

Jim Clarke
Is there a GPath equivalent to the XPATH
'//title[@lang='eng']'?

This would select all 'title'
nodes in the tree (depth search) which have attribute 'lang' set to
'eng'.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gpath <==> XPATH

tugwilson

On 11 May 2006, at 18:55, Jim Clarke wrote:

> Is there a GPath equivalent to the XPATH
> '//title[@lang='eng']'?
>
> This would select all 'title'
> nodes in the tree (depth search) which have attribute 'lang' set to
> 'eng'.

Hi Jim!

something like

x.title.depthFirst().each {

    if (it.@lang == 'eng') {

    .......
    }
}

or

def a = x.title.depthFirst().findAll {it.@lang == 'eng'}
.....

The details will be slightly different depending whether XMLParser or  
XMLSlurper produced x


John Wilson
The Wilson Partnership
web http://www.wilson.co.uk
blog http://eek.ook.org


Loading...