Hi, I ma using the latest dev version to generate xml.

I am getting this result

<?xml version="1.0" encoding="UTF-8" ?>
<nodes>
  <node>
    <product>GG Spiro</product>
    <description>Velmi pohodlná golfová čepice Galvin Green Spiro. Vyrobená z bavlny. Potěší každého kdo si jí nasadí.</description>
    <price>740</price>
  </node>
  <node>
    <product>GG Abel</product>
    <description>Nepromokavá a velmi lehká golfové čepice Galvin Green Abel.</description>
    <price>960</price>
  </node>

I wonder how I could rename "nodes" and "node" tags. Thanks.

Comments

steven jones’s picture

Status: Active » Fixed

You can do this by adding three theme preprocess functions that override the defaults of using the base table to create labels for the root and child nodes.

Have a look at:
template_preprocess_views_data_export_xml_header
template_preprocess_views_data_export_xml_footer
template_preprocess_views_data_export_xml_body
In theme/views_data_export.theme.inc

Status: Fixed » Closed (fixed)

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

dedek’s picture

Thanks for great module. Will you be so glad as to explain how to rename "nodes" "and "node" more detaily (for no programmers)? For "products" and "product".

rosso69’s picture

Thanks for this soultion (#1), i only have question left.

I like to use an id in when i change template_preprocess_views_data_export_xml_body i still get the same root node name.
Is there a way to change $vars['item_node'] for each item?

liquidcms’s picture

Category: support » feature
Status: Closed (fixed) » Active

tpls are cool and all; but sure would be nice if this was a simple views config option.

liquidcms’s picture

hmm.. figured to find node/nodes in those tpl files or the theme.inc; but nope... so bit more work to figure this out... suspect this could be made a bit more simple.

liquidcms’s picture

copy the following functions and paste into your template.php:

template_preprocess_views_data_export_xml_header
template_preprocess_views_data_export_xml_footer
template_preprocess_views_data_export_xml_body

from theme/views_data_export.theme.inc

and rename as:
[yourtheme]_preprocess_views_data_export_xml_header
[yourtheme]_preprocess_views_data_export_xml_footer
[yourtheme]_preprocess_views_data_export_xml_body

and change all occurrences of $vars['view']->base_table to your root node name (like "product" or maybe even t("product")).

steven jones’s picture

Category: feature » support
Status: Active » Closed (fixed)
strykaizer’s picture

For me, this worked in template.php (replacing nodes/node with articles/article)


/**
 * Implements template_preprocess_views_data_export_xml_header.
 */
function mytemplatename_preprocess_views_data_export_xml_header(&$vars) {

  switch($vars['view']->name){
    case 'myviewname':

      // Output clean XML export by replacing nodes/node tags with the specific bundle name
      $vars['root_node'] = "articles";
      $vars['view']->base_table = "article";
      break;
  }