# How to create XML

**URL:** <https://www.ruby-forum.com/t/how-to-create-xml/194640>\
**Category:** Rails\
**Created:** [September 8, 2010, 12:18pm UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640 "2010-09-08T12:18:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [September 8, 2010, 12:18pm UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640/1 "2010-09-08T12:18:23Z")

</div>

hi

I wanna crate XML file in this format.

 214 205 14 44 21 241 14 

when I user  
render :xml =\> @service

then it pick all the data from the table and show. But the format is not  
what I want.

my table name is service-enquiries.

 6 2009-06-22 

How I change the format?

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [September 8, 2010, 8:22pm UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640/2 "2010-09-08T20:22:14Z")

</div>

radhames brito wrote:

> user builder to build your xml template and render the template
> 
> create a file service.xml.builder in the view directory for that  
> controller
> 
> then
> 
> xml.rsp(:status\_code =\> “0”, :status\_message=\> “Success”)  
> xml.daily\_counts  
> @services.each do |service|  
> xml.count(service.code,:date=\> service.date)  
> end  
> end
> 
> then render =\> “services”  
> there you have it
> 
> 214 205 14 44 21 241 14

Hi radhames brito

thanx for your support.  
Can you give the link from where I learn more. How to create XML.

what you tell me above is very nice. But I wanna know how it is working.

so pls if possible give me the link.

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [September 8, 2010, 10:04pm UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640/3 "2010-09-08T22:04:07Z")

</div>

> **[ActionView::Base](https://api.rubyonrails.org/classes/ActionView/Base.html)**
>
> Action View Base Action View templates can be written in several ways. If the template file has a .erb extension, then it uses the erubi template system which can embed Ruby into an HTML document.

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [September 9, 2010, 8:04am UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640/4 "2010-09-09T08:04:24Z")

</div>

radhames brito wrote:

> [ActionView::Base](http://api.rubyonrails.org/classes/ActionView/Base.html)

thank u radhames brito. If I get any problem in this. I’ll again disturb  
u.

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [September 8, 2010, 5:42pm UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640/5 "2010-09-08T17:42:23Z")

</div>

user builder to build your xml template and render the template

create a file service.xml.builder in the view directory for that  
controller

then

xml.rsp(:status\_code =\> “0”, :status\_message=\> “Success”)  
xml.daily\_counts  
@services.each do |service|  
xml.count(service.code,:date=\> service.date)  
end  
end

then render =\> “services”  
there you have it

 214 205 14 44 21 241 14

---

<div class="post-metadata">

**Author:** ![manish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@manish](https://www.ruby-forum.com/u/manish)\
**Post date:** [September 9, 2010, 12:57pm UTC](https://www.ruby-forum.com/t/how-to-create-xml/194640/6 "2010-09-09T12:57:59Z")

</div>

oh please do.
