title: How to create XML from Yaml file using Nokogiri?
body: <p>I want to read and open an .yml file and create an XML using Nokogiri ? Can anybody tell me how to do it ? </p>
  
  <p>This is the Yaml format:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>getOrderDetails: 
    Id: '114'
    Name: 'XYZ' 
  </code></pre>
  
  <p>This is the XML I need:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;product&gt; &lt;id&gt;123&lt;/id&gt; &lt;name&gt;xyz&lt;/name&gt; &lt;/product&gt;
  </code></pre>
  
  <p>And this is the ruby file:</p>
  
  <pre class="lang-ruby prettyprint-override"><code>require 'nokogiri'
  require 'rubygems'
  require 'spec/spec_helper'
  require 'yaml'
  
  @doc = YAML.load(File.open(File.expand_path('/Workspace/XML_Parsing/getDetails_api.yml'‌​)))
  @doc = File.open('/Workspace/XML_Parsing/getDetails_api.yml')
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.doc {
      @doc.each do |o|
        o.doc.child {
          puts "eval(#{doc(:getDetails(['Id']))})"
          puts "#{doc['NameCode']}"
          #o.OrderNo
          #o.EnterpriseCode
        }
      end
    }
  end
  
  puts builder.to_xml
  </code></pre>