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).

Files: 
CommentFileSizeAuthor
#11 views_data_export-1218896-specify-xml-elements.patch5.55 KBSteven Jones
PASSED: [[SimpleTest]]: [MySQL] 81 pass(es). View
#8 views_data_export-1218896-8.patch3.82 KBroderik
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View
#5 views_data_export-1218896-5.patch4.38 KBDmitriy.trt
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1218896-5.patch. Unable to apply patch. See the log in the details link for more information. View
#2 views_data_export-1218896-1-svn.patch2.98 KBskilip
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1218896-1-svn.patch. Unable to apply patch. See the log in the details link for more information. View

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
StatusFileSize
new2.98 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1218896-1-svn.patch. Unable to apply patch. See the log in the details link for more information. View

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

StatusFileSize
new4.38 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1218896-5.patch. Unable to apply patch. See the log in the details link for more information. View

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
StatusFileSize
new3.82 KB
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View

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
StatusFileSize
new5.55 KB
PASSED: [[SimpleTest]]: [MySQL] 81 pass(es). View

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.