First of all thanks for this module.
It's working great for some of my priojects.

Now I am looking for a feature I have not found in this module.

I would lik to add anattribute to the items.


node title

Comments

pindaman’s picture

I would like the xml rows to have attributes.

<nodes>
<node ID="custom id">   (maybe a token as custom id?)
</node>
</nodes>
cdmo’s picture

It doesn't seem that there is any way to create an XML document with attributes for D7 using any contributed module, including this one. If I'm wrong, please correct me. Services Views does something similar to this module, you can output xml with no attributes. You also don't have any control in terms of nesting. I'm thinking that I might have to just output the fields I want in a view, and then use a combination of the views pre render hook along with templating.

steven jones’s picture

Status: Active » Fixed

Yeah, tempting would be the way to go here I think. Sorry!

Status: Fixed » Closed (fixed)

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

shaxa’s picture

Title: attributes for items » Attributes for xml items
Assigned: Unassigned » shaxa
Category: Support request » Feature request
Issue summary: View changes
Status: Closed (fixed) » Needs work

We have to workout this as it is common usage.

shaxa’s picture

Here is a patch for doing this. So when you use the patch on settings of your xml file format you will have checkboxes for which fields you would like to use as attributes. And when you check those fields what is the attributes name which you are using for it. Then magic happens. Note that it will get the name of the attribute from the settings and then will get the value of the field as you display it. So if you display a link it will show a link so be careful what you use as field value. Also if cdata wrapper is checked it will show it as well in the attribute.

shaxa’s picture

Status: Needs work » Needs review
guruslot’s picture

Dear ShaxA, thank you so much for a nice patch I was looking for. The only question I have is that if I exclude fields from display they also hidden from attributes. So I need move those fields from body to attributes. Will be very appreciate for advice on how to approach that in best way. Thanks again!

netzkombuese’s picture

Hi there.
This one seems to be exactly what I need for one of our projects.
Unfortunately I can`t apply the patch to 7.x-3.x-dev.
Could you just tell me which version do I have to apply this patch to?

EDIT: Got it. Thanks

the_paulus’s picture

I had the same issue regarding fields showing as both attributes and nodes. I just modified the theme/views-data-export-xml-body.tpl.php as follows:

<?php foreach ($themed_rows as $count => $row): ?>
  <<?php print $item_node; ?><?php print !empty($item_node_attributes[$count]) ? ' ' . $item_node_attributes[$count] : ''; ?>>
<?php foreach ($row as $field => $content): ?>
<?php if(!in_array($field, $options['item_node_attributes_fields'])): ?>
    <<?php print $xml_tag[$field]; ?>><?php print $content; ?></<?php print $xml_tag[$field]; ?>>
<?php endif; ?>
<?php endforeach; ?>
  </<?php print $item_node; ?>>
<?php endforeach; ?>
guruslot’s picture

Is it possible to change output of some fields like written below within
tags?

<offer id="100">
   <vendor>Apple</vendor>
   <model>iMac</model>
   ...
<param name="Wi-Fi" unit="">Available</param>
   <param name="Screen size" unit="in">27</param>
   <param name="Weight" unit="kg">13.8</param>
</offer>
denix’s picture

Version: 7.x-3.x-dev » 7.x-3.2
Status: Needs review » Needs work

Hi all,
I've applied the patch to version 3.2 but it does not work as expected

denix’s picture

Status: Needs work » Needs review

Sorry, my bad. Few drush cc all and the option was there. thanks

aleevas’s picture

StatusFileSize
new8.03 KB
new2.51 KB

Was combined patch from #6 and #10 and re-rolled against 7.x-3.x branch
And in this state it works for me.

sano’s picture

#14 works for me with version 7.x-3.2. Thank you.

steven jones’s picture

Status: Needs review » Closed (won't fix)

Sorry for the lack of attention to your issue, please accept my apologies.

Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.

As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.

If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, the please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.

Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated and the Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)