我正在尝试让我的 rails 应用程序以某种格式生成 XML 文件,到目前为止,我已经让应用程序使用
format.xml { render xml: @agencies }
产生
<agencies type="array">
<agency>
<address>12 dansu ct</address>
<created-at type="datetime">2013-09-17T14:03:11Z</created-at>
<email>t@t.com</email>
<id type="integer">1</id>
<imageBgUrl>another.jpg</imageBgUrl>
<imageThumbUrl>image.jpg</imageThumbUrl>
<latitude type="float">12.4</latitude>
<longitude type="float">12.43</longitude>
<telNo>94959525</telNo>
<title>Paul</title>
<updated-at type="datetime">2013-09-17T14:03:11Z</updated-at>
<zipCode>3210</zipCode>
</agency>
</agencies>
虽然我需要它看起来像
<?xml version="1.0" encoding="UTF-8"?>
<entries type="array">
<entry>
<address>12 dansu ct</address>
<created-at type="datetime">2013-09-17T14:03:11Z</created-at>
<email>t@t.com</email>
<id type="integer">1</id>
<imageBgUrl>another.jpg</imageBgUrl>
<imageThumbUrl>image.jpg</imageThumbUrl>
<latitude>37.784062</latitude>
<longitude>122.391579</longitude>
<telNo>94959525</telNo>
<title>Paul</title>
<updated-at type="datetime">2013-09-17T14:03:11Z</updated-at>
<zipCode>3210</zipCode>
</entry>
</entries>