Skip to content

Instantly share code, notes, and snippets.

@mmack
Created July 17, 2010 10:31
Show Gist options
  • Select an option

  • Save mmack/479420 to your computer and use it in GitHub Desktop.

Select an option

Save mmack/479420 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'libxml'
include LibXML
class PostCallbacks
include XML::SaxParser::Callbacks
def on_start_element(element, attributes)
if element == 'product'
#puts "start product"
@single_xml_doc = ""
else
if not @single_xml_doc.nil?
@single_xml_doc = @single_xml_doc + element
end
end
if element == 'b275'
puts element.inspect
puts attributes.inspect
end
end
def on_end_element(element)
if element == 'product'
#puts @single_xml_doc
#puts "end product"
@single_xml_doc = ""
end
end
end
parser = XML::SaxParser.file("20091213_02080980_OUSS.xml")
parser.callbacks = PostCallbacks.new
parser.parse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment