From: BA Date: 2005-06-24T10:59:44+09:00 Subject: Re: REXML libraries and parsing issues Yes, I want to extract the PDAT element, however, I want to use the B110 tag to find this element. The XML *is* predictable, however, there are variations in the placement of the elements (there could be several different address fields and/or many paragraphs that need to be parsed/searched). The files are *extremely* large (some could be as large as 1-2GB). I would prefer to do all of the processing in Ruby if this is possible (want to use the OO functionality for the text processing I want to do) and would like to also incorporate regex if possible (started doing this by parsing the file line by line, however, ran into malformed XML where I decided that I needed to use the database functionality of XML. Not sure if DOM would work. Could not get XPath to work. The listener was, quite frankly, a SWAG. Thanks. On Jun 23, 2005, at 7:50 PM, James Britt wrote: > 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 >