logo       

Re: Evaluating dynamic GPath: msg#00071

lang.groovy.user

Subject: Re: Evaluating dynamic GPath


On 5 Oct 2004, at 23:06, Dion Almaer wrote:

Hi guys -

Is there a nice clean way in which you can take a GPath expression as a
String and kinda evaluate it?

foo = new XmlParser().parse("foo.xml")
headings = foo.bar.heading

Is fine, but what about if you wanted to:

foo = new XmlParser().parse("foo.xml")
Headings = evaluateGPath(args[0]) # Where args[0] is "foo.bar.heading"

Anything nifty that can be done?

Dion,

a = 'bar'
b = 'heading'

heading = foo[a][b]

Does that do it for you?



John Wilson
The Wilson Partnership
http://www.wilson.co.uk




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise