If you are building an XML file why are you then converting it to YAML? Why
not write it out as is?


On 4 November 2013 08:51, Rochit Sen <lists / ruby-forum.com> wrote:

> Hi All,
> I am reading an excel file and then generating a XML file. I am using
> the below code. I am using Builder to do soo. Below i thought that as i
> have a 'x' object of builder, i can write it to a yaml file using the
> dump method.
>
> CODE:
> def generate_xml()
>  x = Builder::XmlMarkup.new(:target => $stdout, :indent => 1)
>  x.instruct!
>  x.comment! "A test xml for test cases"
>  x.FileName "#{@p}"
>  x.TotalCases "#{@t}"
>  x.Contents "#{@c}"
>  File.open('dump.xml','w') {|f| f.write(YAML.dump(x))}
>  puts "generated xml" #Just to print this in console
> end
>
> When i run below i get error -
> C:/Ruby193/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:413:in
> `dump_coder': undefined method `name' for #<IO:<STDOUT>> (NoMethodError)
>
> OR what could be another approach to generate an xml file?
>
> Thanks
>
> --
> Posted via http://www.ruby-forum.com/.
>