Is it possible to specify the 'Root element name' and 'Top-level child element name' for XML exports ?

views_datasource allows specifying these, where views_data_export outputs

<nodes>
<node>
specified fields...
</node>
</nodes>

Or did I miss this option? (I'm using the 7.x version).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven Jones’s picture

No, we base it on the base table, but there's nothing stopping us from adding this option.

skilip’s picture

Status: Active » Needs review
FileSize
2.98 KB

1+ and a patch. I'm sorry for the SVN patch. It's just a few lines of code ;)

duncan.moo’s picture

so I did the same as I do on other views to override the theme, but it made no difference:

<?php
// Short tags act bad below in the html so we print it here.
print '<?xml version="1.0" encoding="UTF-8" ?>';
?>

<items>
<?php foreach ($themed_rows as $count => $row): ?>
  <item>
<?php foreach ($row as $field => $content): ?>
    <<?php print $xml_tag[$field]; ?>><?php print $content; ?></<?php print $xml_tag[$field]; ?>>
<?php endforeach; ?>
  </item>
<?php endforeach; ?>
</items>

The view detected the override template file, but the row items still come out as and , not and as I would like. Is there a way of doing this through templates?

duncan.moo’s picture

Just switched to using views_datasource for what I am trying to do and it is a far simpler solution which does allow you to change the root and row items in your feed.

Dmitriy.trt’s picture

Re-rolled against latest git code and fixed it a bit: sites can upgrade from original module without having to re-configure each XML display.

zrpnr’s picture

Patch in #5 worked for me, the defaults show up correctly when no values are set.

Status: Needs review » Needs work

The last submitted patch, views_data_export-1218896-5.patch, failed testing.

roderik’s picture

Status: Needs work » Needs review
FileSize
3.82 KB

Mindless* reroll; don't credit me.

* I did verify structure of code/changes is still the same and remove trailing space somewhere; am not familiar with the code's logic though.

joshf’s picture

#8 worked great for me; thanks for the patch!

Steven Jones’s picture

Status: Needs review » Needs work
Issue tags: +Need tests
Steven Jones’s picture

Status: Needs work » Needs review
Issue tags: -Need tests
FileSize
5.55 KB

Here's a patch, based on #8, but with tests, if the test bot likes it, I'll commit it.

Steven Jones’s picture

Status: Needs review » Fixed

Thanks everyone! Committed to 7.x-3.x.

Steven Jones’s picture

Version: 7.x-3.x-dev » 6.x-2.x-dev
Status: Fixed » Patch (to be ported)

We should probably backport this to 6.x-2.x.

Steven Jones’s picture

Status: Patch (to be ported) » Fixed

Pushed to 6.x-2.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.