Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/delano/saxony

Parse gigantic XML files with pleasure and without running out of memory. (NOT MAINTAINED)
https://github.com/delano/saxony

Last synced: 2 months ago
JSON representation

Parse gigantic XML files with pleasure and without running out of memory. (NOT MAINTAINED)

Awesome Lists containing this project

README

        

## Saxony - 0.3 ##

**Parse gigantic XML files with pleasure and without running out of memory.**

## Example ##

sax = Saxony.new :SomeObject, 1000
sax.parse 'path/2/huge.xml' do
xml # => The XML containing 1000 SomeObjects
doc # => Nokogiri object for 1000 SomeObjects
total_count # => Total number of SomeObjects processed
elapsed_time # => time processing current batch
path # => Current file being processed
fh # => Output file handle
end

# Process multiple files in parallel using Kernel.proc.
# By default
Saxony.fork ['path/2/huge.xml', 'path/2/huger.xml'] do
# Inside the block, everything is the
# same as calling sax.parse above.
doc.xpath('//Listing').each do |l
type = listing.xpath("Type").first.text
fh.puts listing if type == 'some_criteria'
end
end


## Credits

* Delano Mandelbaum (http://solutious.com)

## Thanks

* [Nokogiri](http://nokogiri.org/)

## License

See LICENSE.txt