4

am converting xml file to json, it throws error

The document "some xml data" does not have a valid root. 

am using json gem to conver, my code is

 require 'json'
 scheduledoc = "xmlfile"
 scheduleData = Hash.from_xml(scheduleDoc).to_json
 puts "schedule json #{scheduleData}

how to convert xml to json in rails.

4

1 に答える 1