我正在使用Ruby Gem Builder,我需要这个输出..
<?xml version="1.0" encoding="utf-8"?>
<fileAttachment> "name of file here.xls"
<Data>zip</Data>
<Size>7434</Size>
</fileAttachment>
我的代码如下,但“fileAttachment”旁边的文件名不起作用..这很简单,我只是没有看到它?错误说我不能将文本与块混合..有道理我只是不知道正确的语法。
xml = Builder::XmlMarkup.new(:indent => 2 )
xml.instruct! :xml,:version=>"1.0", :encoding => "utf-8"
xml.fileAttachment("name of file here.xls") do
xml.Data "zip"
xml.Size "7434"
end
答案 0 :(得分:1)
我认为你想使用text!
方法:
xml.fileAttachment do
xml.text! "name of file here.xls"
xml.Data "zip"
xml.Size "7434"
end