Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'nokogiri'
- class Parser < Nokogiri::XML::SAX::Document
- def start_element(name, attrs = [])
- puts name
- end
- def characters(string)
- string.strip!
- puts string
- end
- def end_element(name)
- puts name
- end
- end
- Nokogiri::XML::SAX::Parser.new(Parser.new).parse(File.open('sax_example3.xml'))
- <?xml version="1.0" encoding="UTF-8"?>
- <root>
- <ISA type="array">
- <ISA>
- <I02>
- <name>Information1</name>
- <value>
- <raw>00</raw>
- <description></description>
- </value>
- </I02>
- <I02>
- <name>Information2</name>
- <value>
- <raw></raw>
- <description nil="true"/>
- </value>
- </I02>
- </ISA>
- </ISA>
- </root>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement