Skip to content

Instantly share code, notes, and snippets.

@bryanl
Created January 19, 2009 21:49
Show Gist options
  • Save bryanl/49192 to your computer and use it in GitHub Desktop.
Save bryanl/49192 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
class MyDoc < Nokogiri::XML::SAX::Document
def start_element(name, attrs)
@count ||= 0
@count +=1 if name == "item"
end
def end_document
puts "found #{@count} items"
end
end
cve = "allitems.xml"
xml = Nokogiri::XML::SAX::Parser.new(MyDoc.new)
xml.parse_file(cve)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment