# Huge XML Template

**URL:** <https://www.ruby-forum.com/t/huge-xml-template/177514>\
**Category:** Rails\
**Created:** [October 19, 2009, 3:56pm UTC](https://www.ruby-forum.com/t/huge-xml-template/177514 "2009-10-19T15:56:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinathbtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@srinathbtech](https://www.ruby-forum.com/u/srinathbtech)\
**Post date:** [October 19, 2009, 3:56pm UTC](https://www.ruby-forum.com/t/huge-xml-template/177514/1 "2009-10-19T15:56:59Z")

</div>

Hi,

I am having a xml template containing 5000 lines of code .  
Now i need to generate the template dynamically in ruby on rails .  
My requirement is every time a user clicks on GO , a new xml template  
will generate for every user like “username.xml”.  
I am not showing the xml template on screen , it will generate and  
create on backend .  
The template contains almost 3000 lines of code as static and only some  
lines will be customized.  
How should i start? Do i need to write by hand all lines using xml  
builder or  
is there any alternative ??

thanks,  
sri…

---

<div class="post-metadata">

**Author:** ![srinathbtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@srinathbtech](https://www.ruby-forum.com/u/srinathbtech)\
**Post date:** [October 19, 2009, 4:00pm UTC](https://www.ruby-forum.com/t/huge-xml-template/177514/2 "2009-10-19T16:00:58Z")

</div>

Srinath A. wrote:

> Hi,
> 
> I am having a xml template containing 5000 lines of code .  
> Now i need to generate the template dynamically in ruby on rails .  
> My requirement is every time a user clicks on GO , a new xml template  
> will generate for every user like “username.xml”.  
> I am not showing the xml template on screen , it will generate and  
> create on backend .  
> The template contains almost 3000 lines of code as static and only some  
> lines will be customized.  
> How should i start? Do i need to write by hand all lines using xml  
> builder or  
> is there any alternative ??

You don’t have to use Builder for XML. ERb and (in most cases) Haml  
would work just as well.

But if 3000 lines are going to be static, perhaps you can somehow give  
the user just the non-static part?

> thanks,  
> sri…

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![srinathbtech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@srinathbtech](https://www.ruby-forum.com/u/srinathbtech)\
**Post date:** [October 19, 2009, 4:05pm UTC](https://www.ruby-forum.com/t/huge-xml-template/177514/3 "2009-10-19T16:05:56Z")

</div>

Hi,  
Thanks for reply.

The same xml template will generate every time, but only some parts are  
customized .

The main motto is the total generation will go behind the scenes and  
write to a new xml file each time .  
I should be able write some ruby code , there some parts where i need to  
do looping.  
so I am expecting Ruby + xml file .  
what about REXML ??

thanks  
sri

Marnen Laibow-Koser wrote:

> Srinath A. wrote:
> 
> > Hi,
> > 
> > I am having a xml template containing 5000 lines of code .  
> > Now i need to generate the template dynamically in ruby on rails .  
> > My requirement is every time a user clicks on GO , a new xml template  
> > will generate for every user like “username.xml”.  
> > I am not showing the xml template on screen , it will generate and  
> > create on backend .  
> > The template contains almost 3000 lines of code as static and only some  
> > lines will be customized.  
> > How should i start? Do i need to write by hand all lines using xml  
> > builder or  
> > is there any alternative ??
> 
> You don’t have to use Builder for XML. ERb and (in most cases) Haml  
> would work just as well.
> 
> But if 3000 lines are going to be static, perhaps you can somehow give  
> the user just the non-static part?
> 
> > thanks,  
> > sri…
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid
