I am struggling to see how I would go about extracting data from an XML
file like so:
- 00000
- 100000000
- THIS IS A NEW RECORD
- 00000
- 100000000
My code thus far is
require ‘rexml/document’
xml = REXML::Document.new(File.open(“H:\test.xml”))
csv_file = File.new(“H:\data.csv”, “w”)
xml.elements.each("//event") do |e|
csv_file.puts e.attributes[‘id’] << “|” <<
e.elements[‘object class=“com.########l”’].text << “|” <<
e.elements[‘void property="###########"/long’].text << “|” <<
e.elements[‘void property=“description”/string’].text << “|” <<
e.elements[‘void property=“downloaded”/long’].text
end
This is however failing.
Any ideas?
Many thanks