From: James Britt Date: 2005-06-24T10:50:19+09:00 Subject: Re: REXML libraries and parsing issues BA wrote: > First off, let me say right up front that I am a newbie wrt Ruby. > > I am trying to parse an XML file, however, am having all kinds of > trouble. I am using the REXML libraries and the sax2parser/listener. > In the sax2listener, I can use the character/text part of the method, > however, I cannot for the life of me figure out how to parse out JUST > WHAT I WANT. Here is what the file looks like as follows: > > this is the text I need > > If I use :character, %w{PDAT} {|text| puts text} ... I get the text > "this is the text I need" printed out. If I use the B110 or any > combination, I cannot get it to work. Anyone know how to get the > sax2parser/listener to parse the file and allow me to be selective about > what I parse out of the file? Thanks for any/all help in this > endeavor!!!!!!!!!! What, exactly, do you want? To extract the text from the PDAT element? How predictable is the XML? Are the files as small as your example? Are regular expressions an option? Or using a DOM and XPath? How did you decide to use the listner? James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys