How do I use XML Builder to create xml in rails?
Posted
by Angela
on Stack Overflow
See other posts from Stack Overflow
or by Angela
Published on 2010-05-29T19:41:19Z
Indexed on
2010/05/29
19:42 UTC
Read the original article
Hit count: 314
ruby-on-rails
|Xml
I am trying the following, but the output XML is badly formed:
def submit xml = Builder::XmlMarkup.new
xml.instruct!
xml.mail
xml.documents
xml.document
xml.template
xml.source "gallery"
xml.name "Postcard: Image fill front"
@xml_display = xml
end
I need it to look more like this:
<?xml version="1.0" encoding="UTF-8"?>
<mail>
<documents>
<document>
<template>
<source>gallery</source>
<name>Postcard: Image fill front</name>
</template>
<sections>
<section>
<name>Text</name>
<text>Hello, World!</text>
</section>
<section>
<name>Image</name>
<attachment>...attachment id...</attachment>
</section>
</sections>
</document>
</documents>
<addressees>
<addressee>
<name>John Doe</name>
<address>123 Main St</address>
<city>Anytown</city>
<state>AZ</state>
<postal-code>10000</postal-code>
</addressee>
</addressees>
</mail>
© Stack Overflow or respective owner