jastrachan | 6 Oct 09:48 2004
Picon

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"

Something like this?

evaluator = new GroovyShell()
evaluator.foo = new XmlParser().parse("foo.xml")
evaluator.evaluate(args[0])

James
-------
http://radio.weblogs.com/0112098/


Gmane