Export views results as XML
jasonwhat - November 9, 2006 - 17:10
| Project: | Views Bonus Pack |
| Version: | 5.x-1.x-dev |
| Component: | Views Export |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
views does a great job of filtering and laying out data on the page. I'm imagining it wouldn't be that hard to add the ability to create a CSV fille from the views data. It would also be great to create a valid XML file (in my exprience the RSS in views is not very clean and does not reflect user filters see, http://drupal.org/node/93072).
I know the new import/export api exists and maybe should have something to do with this, but it seems views already does a good job of filtering and extracting data, so why not add two other displays of xml and csv?

#1
These are perfectly fine ideas and I think someone should do them but they would go into the bonus pack, not Views itself.
#2
Yeah, I don't think they should be in the core of views, but not sure where to file this to have it go elsewhere.
#3
The Views Bonus pack, without a doubt.
#4
+1
This is a great idea... I'm trying to develop some functionality based around a simple flash file calling on some equally simple xml data, and I'm convinced that Views is by far and away the best way of spitting out that xml data. Unfortunately I ain't no coder... but if anyone has the time to work on this I'd be in your debt forever!
Cheers,
Tom
#5
Done, I have CSV and XML views finished in the Bonus pack. Will upload later.
#6
did this ever make it?
#7
ptalindstrom, yes this has been completed. I'm still having the functionality of the code reviewed before I'll submit this. Also I am working out my CVS access which has some probs.
#8
lapurd, what's the current status? I've been wanting to try this for a while... :)
#9
Hi there again. OK Appel, I still have this very annoying CVS access problem over here (it seems my account has been disconnected on the Drupal CVS server itself).
I have tested my code updates locally and I can't find any bugs. I have attached an updated 4.7 module, but I can't seem to do anything usefull around here because of my CVS problem. However, if anyone wants to test this, you can use the attached file which gives you CSV and XML export views.
Let me know if there is a problem or if it works for you.
Casper
p.s. the code follows all Drupal code format standards
#10
Thanks! I've tried it out and it seems to be working okay. I've noticed there's no first row with column names, though I'm not sure if the patch is to blame. Could very well be something that escaped my attention or perhaps it's technically not possible. If it is possible, wouldn't it make sense to use the label values from the used fields? Thanks again!
#11
For what it's worth, here's some code to have the column names printed on the first row of the CSV file (It worked for me). Put this between line 229 and 230 of lapurd's views_bonus.module to make it work.
foreach ($view->table_header as $h) {$header[] = $h['data'];
}
$rows[] = $header;
#12
Still having problems getting this in to CVS? Just installed and it works a treat. Excellent stuff, includ9ing the additional column heading code in the above comment.
#13
Is there a version 5.0 version in the works? I am very interested in putting this feature to use for several drupal sites. I can't believe the feature hasn't been developed already... it's incredibly useful.
#14
This is great, although I was hoping it wasn't just another view, but attached to a table view. That way users could download the current table view they are viewing. Has anyone tried putting the code into the header or footer to see if it works?
#15
> I was hoping it wasn't just another view, but attached to a table view. That way users could download the current table view. . .
That would be a great way to deliver this functionality. Possible?
#16
Sure, put a link to the page view in the page footer area of the parent view. ;)
I'm going to mark this RTBC. It still has a couple bugs, but overall, this is a fantastic improvement. We used this on the OSCMS site to export a list of registered users to Yahoo! a few times, and I didn't hear anyone screaming. :)
#17
There isn't a patch here, and the given views_bonus.module is old enough that it doesn't even contain the reconfiguration for the new setup where each plugin is its own fi.e
#18
Actually, I think hsfdrupal has a point. A user could filter the data through exposed filters and then download the filtered data directly in CSV format. Very intuitive. I see many uses for this scenario!
#19
I meant to say 'mshaver', it's him who has a point! Bareuh!
#20
Oops, I meant to make the other CSV patch RTBC. Sorry!
#21
any news on this and VERSION 5? i cant install this on version 5.. and i would like a views plugin that will let me view the all the fields as seperate XML tags...
#22
I eagerly await version 5 for this....this will very useful.
#23
I really quote the previous reply ..... a 5 version would be a god's gift
#24
I am still refining - but this version did basically work. Use it on your own risk. You need to have import-export installed!
#25
Some refinements for better use with excel. You still need to import via Data->import. If you just open the file, you'll get problems with character-settings.
#26
could you please try to merge this with http://drupal.org/node/114115? BTW, I *love* the XML idea.
#27
nm... this is results and the other is the view itself... keep up the good work and *roll a patch*
#28
Definitely try to get the XML stuff into this one.
#29
If you check out the latest CVS, you'll notice a big change in the Views Bonus Export module. I moved a bunch of things around to make it easier to extend (with argument selectors too), so if we just add in your XML stuff, we should be good.
#30
Changing the title to focus on the XML stuff.
#31
Is the CVS version for Drupal 5.x or 6?
I'm excited to try it out.
#32
The ability to export as CSV and DOC is in there. Export as XML isn't, I believe.
#33
is it possible yet to create a custom XML view .. this would help soo much with flash sites :)
#34
For Flash stuff, the Services module, along with AMFPHP, is the way to go ;-) .
#35
@merlinofchaos: as Rob said, the AMFPHP + services modules. Those will output in a flash-friendly method.
#36
any word on xml exports? this would dramatically helpful as there are a ton of programs that can parse xml where this would be handy...ie exporting articles to indesign templates.