A
aidy
Hi,
I am trying to build a dynamic hash map
<CODE>
def extract(xml, path)
require 'rexml/document'
xml = xml.to_s.gsub("utf-16", "utf-8")
doc = REXML:ocument.new(xml)
doc.root.each_element(path) do |element|
element.each_element do |node|
puts "name: #{node.name} text: #{node.text}"
@xml_data = {node.name => node.text}
end
end
return @xml_data
end
</CODE>
However, the @xml_data is always returning 1 element
Thanks
Aidy
I am trying to build a dynamic hash map
<CODE>
def extract(xml, path)
require 'rexml/document'
xml = xml.to_s.gsub("utf-16", "utf-8")
doc = REXML:ocument.new(xml)
doc.root.each_element(path) do |element|
element.each_element do |node|
puts "name: #{node.name} text: #{node.text}"
@xml_data = {node.name => node.text}
end
end
return @xml_data
end
</CODE>
However, the @xml_data is always returning 1 element
Thanks
Aidy