如何在RoR中向用户显示现有的xml文件

pie*_*fou 4 xml firefox ruby-on-rails render view

我有一个xml文件,我想显示(渲染)它,因为它是用户,即我想保留标签.我应该怎么做RoR?

我试过了render :file=>"/path/to/file.xml",但标签<product>消失了.

//file.xml
<product>car</product>
Run Code Online (Sandbox Code Playgroud)

更新:我发现该行为依赖于浏览器

  • Mozilla/5.0(X11; U; Linux i686; en-US; rv:1.9.0.3)Gecko/2008101315 Ubuntu/8.10(强悍)Firefox/3.0.3

    标签保存.

  • Mozilla/5.0(Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.15)Gecko/2009101601 Firefox/3.0.15

    标签消失了.

jhw*_*ist 6

你试过添加吗?

:content_type => 'application/xml'
Run Code Online (Sandbox Code Playgroud)

你的渲染线?

render :file=>"/path/to/file.xml", :content_type => 'application/xml'
Run Code Online (Sandbox Code Playgroud)