From: David Vallner Date: 2006-11-07T11:24:35+09:00 Subject: Re: REXML --------------enigF9D6B5236ACE2603700BC85A Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable pdg wrote: > Assuming I go with the Ruby pull parser, how do I use this in my code. > I see from the link the code sample, but I have no idea how to throw > that into my code and make it work. Any suggestions. >=20 Generally, you should have some layer between XML input, and processing the records themselves. E.g. a trivial Song class, or at least a hash. Personally, I'd make a XMLSongList class that's enumerable (implements #each), and rework the REXML code that works for small files into one that yields a Song object for each of the records in succession by querying the tree accordingly. That shouldn't then be too hard to rework so that while #each is running, it opens a pull parser, and for each yield, builds up a Song object going through the record in the order how the elements appear in the XML file, instead of a random one. Once you isolate the code that manipulates the XML to the smallest significant unit (a song record in this case, I presume), it shouldn't be conceptually that difficult to rework from a tree parser to a pull parser. The code probably will get a little messier and verbose, but the main shift of thinking is in not asking the XML for what your object needs, but feeding an object what the XML has. > PS: idiot (slaps head). Yes it was 5-6meg not gig! >=20 6MB is still Huge (tm) for a XML file. --------------enigF9D6B5236ACE2603700BC85A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFT+5ay6MhrS8astoRAkkFAJ9G4g4kyo6mdKIywnBnXWJ9XpexGACeODK3 GDwxjcj8VJX8nctYiLUgV0I= =Jh35 -----END PGP SIGNATURE----- --------------enigF9D6B5236ACE2603700BC85A--