Many new PHP developer looking for how to easily read the xml file. In this tutorial I will show you how to read the xml file using PHP language. Here I given the sample code for parsing the XML using PHP.

Create XML document with Ruby on rails

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

http://www.ruby-lang.org/en/

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:

Create XML document with Ruby on rails
Create XML document with Ruby on rails

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “Create XML document with Ruby on rails”

Leave a Reply to Al Cancel reply

Your email address will not be published.