UI Deploy

Curated, Short, Web UI Dev we Love.

Parsing Big XML Files with Nokogiri

Parsing XML files is a pretty common problem. There are tons of libraries out there to help accomplish this. At Viget, we typically use Nokogiri for our XML needs.

Recently, I was faced with the challenge of parsing a 60MB, 1.1+ million line XML document into a DOM (Document Object Model -- basically a traversable XML node tree). Nokogiri has a really fast XML parser that will generate a DOM for you. Totally awesome -- with one major caveat -- the entire DOM lives in memory.

view source

Advertisement