I'm building an XML feed for my application and am wondering what the best way to implement it would be.
I have an Item class, with a field "related_item," which right now contains ids to related items in an array)
For instance, I could have the following item:
id: 3
name: an item
related_items: [67, 94, ...]
and would like to get the following xml when I access mysite.com/items/3.xml:
<item>
<id>3</id> <name>An item</name>
<related-items>
<related-item> <id>67</id> <name>A related items</name> </related-item>
<related-item> <id>94</id> <name>Another related items</name> </related-item>
<related-item> ... </related-item>
</related-items>
</item>
What's a good way to accomplish that (this is just an example, I will actually have many more fields and would like to avoid rewriting as much as I can)? Thanks