ruby如何生成xml文件

phpkunpeng 2006-07-23 09:30:15
ruby如何生成xml文件,初学 用的是ruby on rails  是不是直接用rails就可以生成,还是类似php写each可以形成xml?
...全文
921 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
killme2008 2006-10-14
  • 打赏
  • 举报
回复
使用rxml模版
比如你在controller查询出结果赋给变量@orders,循环输出xml文件

xml.order_list(:for_product => @product.title) do
@orders.each{|o|
xml.order do
xml.name(o.name)
xml.email(o.email)
end}
end
gigix 2006-07-31
  • 打赏
  • 举报
回复
> 我觉得rails对XML的支持并不是很好,不如自己读写文件

1. generating xml documents
and
2. accessing file
are separated things...
leihome 2006-07-31
  • 打赏
  • 举报
回复
我觉得rails对XML的支持并不是很好,不如自己读写文件
File.open( fpath, "w" ) do |f|
f<< xml
gigix 2006-07-30
  • 打赏
  • 举报
回复
what do you want to do? or in other words, what do you want to ask? do you want to know how to create an application with rails? or, as the title of your post suggests, do you want to know how to manipulate xml files with ruby? would you please do us a favor, tell your requirement clearly?
phpkunpeng 2006-07-30
  • 打赏
  • 举报
回复
我用的是ror,第一步怎么做?
先生成controller?
gigix 2006-07-30
  • 打赏
  • 举报
回复
well...at least you can generate xml with REXML, just like nonocast said. however rails provided another powerful approach building xml documents: rxml templates. please refer to section 17.2 of the book "Agile Web Development with Rails" for detailed discussion.
phpkunpeng 2006-07-30
  • 打赏
  • 举报
回复
抱歉 我描述一遍
我用的是ruby on rails 我想读数据库生成一个xml文件
第一次用的是生成rhtml 我的步骤是先生成一个controller,和views.现在是想要xml不会了
nonocast 2006-07-25
  • 打赏
  • 举报
回复
MFC能脱离C++吗?
Struts能脱离Java吗?
有点小晕
elsjc 2006-07-24
  • 打赏
  • 举报
回复
顶一下.
nonocast 2006-07-24
  • 打赏
  • 举报
回复
use REXML lib

something like

require ' rexml/document'
doc = REXML::Document.new

root = REXML::Element.new(' my-root' )
doc.add_element(root)
puts doc.to_s

具体参看他的help
phpkunpeng 2006-07-24
  • 打赏
  • 举报
回复
怎么生成?脱离rails了吗?
我现在在rails里有个工程
phpkunpeng 2006-07-24
  • 打赏
  • 举报
回复
不太懂楼上的意思,你说的用ruby生成xml是什么?
nonocast 2006-07-24
  • 打赏
  • 举报
回复
我用的是rails 用里面的generator先生成一个controller吗?

用ruby生成XML有什么关系?

你想用xml来配controller?像struts那样还是什么意思?
phpkunpeng 2006-07-24
  • 打赏
  • 举报
回复
谢谢楼上的两位 不过我还是有些不太懂
我用的是rails 用里面的generator先生成一个controller吗?
您能把具体步骤说一下不?

2,763

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ruby/Rails
社区管理员
  • Ruby/Rails社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧