How do I create an XML document with nested children based on node reference filed.

I have 2 content types: Album and Song. Album has a CCK field "songs" that is a node reference with multiple values to Song. How can I get this XML schema:

<albums>
   <album>
      <nid>[Album nid]<nid>
      <songs>
         <song>
            <nid>[Referred Song nid]</nid>
            <title>[Referred Song Title]</title>
         </song>
         <song>
            <nid>[Referred Song nid]</nid>
            <title>[Referred Song Title]</title>
         </song>
         <song>
            <nid>[Referred Song nid]</nid>
            <title>[Referred Song Title]</title>
         </song>
      </songs>
   </album>
   <album>
      <nid>[Album nid]<nid>
      <songs>
         <song>
            <nid>[Referred Song nid]</nid>
            <title>[Referred Song Title]</title>
         </song>
         <song>
            <nid>[Referred Song nid]</nid>
            <title>[Referred Song Title]</title>
         </song>
         <song>
            <nid>[Referred Song nid]</nid>
            <title>[Referred Song Title]</title>
         </song>
      </songs>
   </album>
</albums>

Comments

voxpelli’s picture

Check out #903528: Allow for XML fragments - it allows for doing nested fields by utilizing Views Field View

shadysamir’s picture

That was a nice hint to a good direction. Not sure I can use Views Field View at its current beta state. Worth testing though. I will keep this open for more suggestions

chromix’s picture

Node Reference Views is the best solution I've found to present node reference fields as nested data objects. The only problem is that the formatting for this ends up looking pretty messed up in some cases, particularly when nesting JSON. I'm going to open a new issue for this, I think, so I can contribute my solution for this.

kenorb’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Closing as too old.