[英]Builder GEM XML formatting
I'm using the Ruby Gem Builder, and I need this output.. 我正在使用Ruby Gem Builder,并且需要此输出。
<?xml version="1.0" encoding="utf-8"?>
<fileAttachment> "name of file here.xls"
<Data>zip</Data>
<Size>7434</Size>
</fileAttachment>
My code is below, but the file name next to "fileAttachment" just isn't working.. This is something simple I'm just not seeing it?? 我的代码在下面,但是“ fileAttachment”旁边的文件名不起作用。。这很简单,我只是看不到? The error says I can't mix text with a block.. makes sense I just don't know the correct syntax.
该错误表明我无法将文本与块混合。.很有道理,我只是不知道正确的语法。
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
I think you want to use the text!
我想您想使用
text!
method: 方法:
xml.fileAttachment do
xml.text! "name of file here.xls"
xml.Data "zip"
xml.Size "7434"
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.