Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
voxpelli CreditAttribution: voxpelli commentedCheck out #903528: Allow for XML fragments - it allows for doing nested fields by utilizing Views Field View
Comment #2
shadysamir CreditAttribution: shadysamir commentedThat 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
Comment #3
chromix CreditAttribution: chromix commentedNode 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.
Comment #4
kenorb CreditAttribution: kenorb commentedClosing as too old.