1

I am using Views and Views Data Export to create a page of XML data from a specific node type.

The node type has a taxonomy field with unlimited output so that views returns all the selected terms as a comma separated value.

However, I need to output the taxonomy terms as separate XML nodes rather than a comma separated list of one.

So, I currently get this output:

<nodes>
 <node>
  <nid>12</nid>
  <categories>Corporate, finance</categories>
 </node>
</nodes>

I would like to get the following:

<nodes>
 <node>
  <nid>12</nid>
  <categories>Corporate</categories>
  <categories>finance</categories>
 </node>
</nodes>

The difference being that I have two categories fields instead of one.

Can anyone help, please?

0

In your views panel, if you edit your taxonomy field, one of the options is "Multiple Field Settings", with a checkbox for "Display all values in a single row". If you uncheck this box, you will get multiple rows, however, it doesn't group them into one node. You get the entire node repeated. The setting mentions adding a "group by" to your display, but the data export display doesn't seem to support that.

So I did a search and found this article on drupal.org: https://drupal.org/node/1187712 It looks like there have been a couple of patches created for adding group by functionality. It doesn't look like they've been integrated into the base code, but maybe one of the patches will work for you.

0

I had success using views_field_view to accomplish this. I set up an attachment display in my view that takes an entity ID (nid) as its contextual filter and outputs just the fields I wanted. Then add a views_field_view field to the original view, and you can output the entirety of the other view as an individual field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.