XML is most popular data transfer layer. In every language we need XML parsing. In Ruby there is in build XML strong parsing support.
Create XML document with Ruby on rails
In this post I am going to cover the How to create XML file with simple Ruby code.
TIP: If you are new in Rails than follow step one or go to step two.
1. You need to install Ruby on your computer
2. Open command prompt(for windows) or console(linux)
3. Create file named CreateXML.rb and copy and paste following code
require “rexml/document”
include REXML
string = <<EOF
<xml>
<element attribute=”attr”>first XML document with ruby </element>
</xml>
EOF
doc = Document.new string
print doc
Output will be like this: