Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Create an XML "file" in memory...

Replytotopic

Create an XML "file" in memory

Posted in Forums : Ask a Rails expert

 
Profile

Authority 12
Posting Rating 100
Sign in to rate this post

I have a Flash gallery object that takes an xml file as a parameter to load the images. Creating the xml file is not a problem, I already handled that. My problem is that I have a bunch of these galleries all over my site and the XML is created dynamically from my database and I don’t want to have to worry about reading/writing/updating a bunch of xml files for this purpose. First, I think it will unnecessarily slow. Second, I have to worry about deleting and recreating the xml files to keep them up to date, different file names for everything, etc., etc.

Can I create a file named “gallery.xml” in memory and pass it into my partial’s javascript to fill in the param? An xml string doesn’t work. Already tried it. I also tried using send_data like this:

send_data stream, :filename => 'gallery.xml', :type => 'text/xml', :disposition => 'inline

but that just returns the (properly formatted) xml back to the browser.

 
Pjones

Authority 62
Posting Rating 86
Sign in to rate this post

It depends on what your partial is doing. If your partial expects a params like hash, you could use Hash.from_xml to parse the XML and turn it into a Hash. Otherwise, please post the details of the partial.

 
Profile

Authority 12
Posting Rating 100
Sign in to rate this post

Thanks for the reply. I figured it out. But here’s my code and solution.

My partial looks like this:
<script type="text/javascript" src="/javascripts/slideshow.js"></script> <script type="text/javascript"> // <![CDATA[ XMLFlashSlideshow_v3({swf:'/images/slideshow.swf', w:'600',h:'360',redirect:'',usePreloader:'true', xml: '/images/slideshow.xml, <%= url_for :controller => "magazines", :action => "gallery", :id => @mag -%>', preventCache:'true', disableMultipleXML:'false', initXML:''}); // ]]> </script>

In the javascript, the parameter called ‘xml:’ is where you specify the path to the xml file spelling out the image paths you want to show. Previously I was using send_data to stream a file straight to that parameter but it was just rendering in the browser. But it expects a path to a file. So I created a controller action that triggers the xml send_data method and using url_for, all is well.

I hope this was clear enough to help someone else.

 
Profile

Authority 12
Posting Rating 74
Sign in to rate this post

hi i want to pass a list of playlist in my video so i have used xml for this but it did not reflect any thing on that so how i can do that Thanks Amit Agarwal

 
Profile

Authority 12
Posting Rating 100
Sign in to rate this post

Please provide some more info about how you are using the xml. Is there a flash object looking for a file somewhere or is there some other situation going on here?

 
Profile

Authority 12
Posting Rating 74
Sign in to rate this post

Hi i create the xml file in my public folder and i want to pass some value from my database so i will do this. Thanks
Amit Agarwal

 
Profile

Authority 12
Posting Rating 74
Sign in to rate this post

Hi
Raul Rubio I pass The xml in this formet

######################
Xml Start

<?xml version=”1.0” encoding=”UTF-8”?>
<recommendations> <title>Reporting screenshot from Mint</title> <image>http://122.169.104.164:3003/video_screenshots/bullfighters.wmv.jpg?1207569278</image> <link>http://www.haveamint.com</link>
</recommendations> ###########################
xml End
to show the videos i write this in my public folder but i want to pass images and link from my database so how i have to do
Thanks
Amit Agarwal

Replytotopic

Other Recent Topics

Ask a Rails expert : how to execute the url from my controller

Ask a Rails expert : conditional action caching multiple mongrel clusters

Ask a Rails expert : Using like command in RoR

Ask a Rails expert : Apache ActionController:RoutingError

Ask a Rails expert : Multiple csv file upload based on data in a form

Ask a Rails expert : Exception error code

Ask a Rails expert : Tracking down an issue

Ask a Rails expert : Thread Vs Transaction

Ask a Rails expert : implementing whitelist plugin

Ask a Rails expert : Validation helper

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel