Check out Greg Weber's version of Paul Dix's sax-machine gem:
http://blog.gregweber.info/posts/2011-06-03-high-performance-rb-part1
Parsing large file with SaxMachine seems to be loading the whole file into memory
sax-machine makes the code much much simpler; Greg's variant makes it stream.