brainfck
brainfck

Reputation: 9376

Manipulating biiig XML documents

I want to parse a XML file, change some attributes and write the results in a new XML file. The given XML file is very huge (approx. 2 GB).

Does anyone have experiences handling such XML files using Ruby and can recommend me a library?

Best regards

Upvotes: 1

Views: 78

Answers (1)

Robert Diana
Robert Diana

Reputation: 860

First, I am assuming that you are talking about changing some attributes on a bunch of elements. That being said, you do not want to read the whole document at once (DOM based parsing), you really want to deal with elements as you see them (SAX based parsing). I am not a ruby person, but a quick search turned up some good info on SAX parsing in Ruby, in particular this post http://lucaguidi.com/2008/01/30/ruby-xml-parsing-with-sax.

If you only have a few attributes on a small number of elements, then I would recommend a different approach. First, if you can specify the items you want to change as a regular expression it may be simpler to use a command-line tool like sed to edit the files.

Upvotes: 1

Related Questions