我正在尝试从一个动作发送一个 xml Doc
XML是通过以下方法创建的
def media_xml
x = Builder::XmlMarkup.new
x.instruct!
x.declare! :DOCTYPE, :html, :PUBLIC, "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
x.options{
x.videos{
for m in self.media
x.imageName("static-video-image.png", "target"=>"_self", "html"=>"", "flv"=> m.filename+".flv", "autoStart"=>"false")
end
}
}
x
end
在控制器中,我使用以下
def media
@inspection = @tag.inspections.find params[:id]
respond_to do |format|
format.html { render :nothing => true }
format.xml { render :xml => @inspection.media_xml }
end
end
以下 XML 是结果
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<options>
<videos>
<imageName html="" flv="3504_1245270846028.flv" autoStart="false" target="_self">static-video-image.png</imageName>
</videos>
</options>
<respond_to?:to_xml/><to_xml/>
由于“<respond_to?:to_xml/><to_xml/>”,另一端的解析器给出以下错误
XML Parsing Error: junk after document element
为什么 Rails 将其放入文档中,我该如何摆脱它?
谢谢!