How to create xml file from a slot of content items

I’d love it if I could do this generically:

Make a new content item and template that creates an xml file from all of the items in a slot .

In my dreams it would: Determine what all the fields are (I guess item by item of the things in the slot, though hopefully they’d stay the same - i.e. “sys_title, display_title, body, callout, city” or whatever fields existed)

Create in xml format a node for each item, maybe based on the sys_title

<item> my sys_title for item 1
<body>the body of this item</body>
<callout>the callout</callout>
<city>some city</city>
<item> … the next one in the slot …

Is there a way to find all the fields of an item in the slot?

Anyone done something similar?

Thanks for any thoughts or ideas.

Yup, we have created a custom macro (User Velocity Macros…rx_assembly.vm) that we call from an autoindexer and manual indexer to generate rss feeds. Those are two different templates passing the slot to the macro which generates the xml format.

We had to do a bunch of hand waving (read cloning the assembly node), but this was because we wanted to render the particular item’s slot content as well (Ie. say an image in an image slot in a general content item).

In that macro, we check for the content type via $currItem.getPrimaryNodeType().getType() and then render fields based on the content type. As there are several fields that are constant (sys_title, display_title), those are set before content type specific fields. Because we wanted full control of what each element was called, we didn’t look at creating a generic function that outputs all the fields of the content type. I think if you do a search on the forums, someone may have posted how to get all the fields…

Also see