From: Keith Fahlgren Date: 2007-02-22T11:40:57+09:00 Subject: Re: Rexml - StreamListener - Where I am in the XML? On 2/21/07, beikel.meikel@web.de wrote: > I'm using REXML::StreamListener to analyze a big xml file. My ruby > code looks like this: >... > At the "tag_start" method I need sometimes the information where I am > in the xml. What is my parent tag and so on. Is there is a method to > get this information at this time? Hi, I've used REXML::Parsers::PullParser instead of stream parsing (same general idea), here's an example of a function that waits until it sees a tag that matches element_name and then pulls the text from it: def self.get_element_text(filename, element_name) parser = REXML::Parsers::PullParser.new(File.new(filename)) text = false while parser.has_next? el = parser.pull if el.start_element? and el[0] == element_name text = parser.peek[0] break end end return text end So, while the above certainly won't work for your application, you could try playing a little with parser.peek to see if you can find the child node (or next node, whatever) that you're looking for. HTH, Keith