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 ??
The rails api for Builder::XmlMarkup uses both an â€˜xmâ€™ and â€˜xmlâ€™ object to show how to work with xml, but only the â€˜xmlâ€™ object seems to work. It also doesnâ€™t clearly show how to setup the controller or that the code should go in an xml.builder file. Similarly here, the xml object is used in the view correctly, but also fails mention anything about the controller or type of file the code should go in.
Over at xml.com, the tutorial creates an @xml instance variable of type Builder::XmlMarkup.new and then uses that object in an .rxml view
xml.instruct! xml.posts do @posts.each do |post| xml.post do xml.title post.title xml.body post.body xml.published_at post.published_at xml.comments do post.comments.each do |comment| xml.comment do xml.body comment.body end end end end end end
You can also look for some updated documntation on this link http://developer.apple.com/tools/customizeonrailsleopard.html