Created
July 17, 2010 10:31
-
-
Save mmack/479420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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