How do I use XML Builder to create xml in rails?
- by Angela
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>