Created
March 15, 2009 10:47
-
-
Save yob/79387 to your computer and use it in GitHub Desktop.
This file contains 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" | |
gem "libxml-ruby", "1.1.2" | |
require "libxml" | |
file = File.join(File.dirname(__FILE__),"..","data","entities.xml") | |
reader = LibXML::XML::Reader.file(file) | |
def read_next(reader) | |
while reader.read | |
if (reader.name == "Header" || reader.name == "Product") && reader.node_type == LibXML::XML::Reader::TYPE_ELEMENT | |
str = reader.read_outer_xml | |
reader.next_sibling | |
return str | |
end | |
end | |
end | |
while str = read_next(reader) | |
puts str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment