From: Luke Galea Date: 2005-01-22T09:09:04+09:00 Subject: Re: Xpath like syntax Actually when I posted the original question I had something like JXPath in mind.. or OGNL.. (ognl.org) It's awesome how many alternate implementations have been proposed in answer! Open source at it's best!! On Friday 21 January 2005 10:19, Nicholas Van Weerdenburg wrote: > On Fri, 21 Jan 2005 15:21:45 +0900, Luke Galea wrote: > > Hi all, > > > > curious if there is a nice ruby way to express an xpath like navigation > > of an object graph.. > > > > ie: > > > > XPATH way: > > Countries/Provinces/Cities[ @name = "London" ] > > > > versus > > > > The only Ruby way I can think of: > > countries.collect{ |c| c.provinces.collect {|p| p.cities.select { |c2| > > c2#name == 'London' } } } > > > > Thanks in advance > > I asked a similar question a couple of weeks ago, and there was > nothing existing in the ruby world from the looks of it. > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/125206 > > Some external projects to look at mentioned: > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/125284 > > A code idea: > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/125291 > > JXpath in the Java world seems like it's for exactly this purpose. > http://jakarta.apache.org/commons/jxpath/ > > I haven't worked on the query aspect of my project lately, so I > haven't made up my mind how I'm going to approach it yet. > > Regards, > Nick