5

I want to use the power of views to handle my data which comes from simple xml representing just a grid resp table

<list>
  <listpos id="12312">
    <foo>attr1</foo>
    <bar>attr bar</bar>
    ...
  </listpos>
  <listpos id="124412">
    <foo>attr 2</foo>
    <bar>attr barxy</bar>
    ...
  </listpos>
  ...
  ...
</list>

So the main task is to display that table sortable, exclude some columns, filter and search etc.

Is this possible with views? It would be handled by a plugin i guess? Or are plugin only for output? (I know of the json, atom etc plugin / modules.)

I also tried the feeds module plus xml / xpath parser and let the importer create the nodes so a view can display them. But I have to delete them anyway after user logs out because it's sensitive data and should not be kept on the webserver.

And what about combining this data with other sources i.e. join with a node table?

  • One answer I guess could involve importing your xml to a temp table, and then using views to access it. Though i'm not how this would be accomplished with views. I like your question. It will be interesting to see the answers. – lordg Mar 12 '11 at 11:03
2

There is a module for this: XML Views.

  • 1
    Just as a note to any passer-byers - as of the time of this comment - there are currently no releases for this module and it is 6.x, looks promising though! – electblake Mar 16 '11 at 21:02
  • Porting to 7.x-3.x is easy. It doens't really uses any kind of changed core functionality – Daniel Wehner Mar 20 '11 at 17:26
  • I gave a shot in d7 but couldn't solve it quickly so I postponed that. But I learned from that module about views query plugins and wrote a similar module for yaml files – groovehunter Apr 9 '11 at 10:37
  • We should really create a listing of all query plugins availible. – Daniel Wehner Apr 26 '11 at 5:44
2

The best way to do this would be

  1. Write a module using simple XML library that extracts data from the xml
  2. Store that data into nodes
  3. Use views to show that data

Advantages Using this approach

  1. No overhead of reading the xml again and again for visitors
  2. Say if XML structure changes, you won't have empty or error in your view

In my experience parsing XML every time is very expensive.

But your case is different as xml data is sensitive and needs to be erased from the server every-time, a user logs out.

So creating nodes and deleting them is not a very smart step.

The best way would be to create a custom module using simple xml library and to not use views at all. Store that data in temporary table, show them using your custom module or custom sql query then using the user hook deleting the table and xml, as the user logs out.

1

That's not entirely true. Views can use handlers which do not rely on SQL. http://drupalmodules.com/module/entityfieldquery-views-backend is an example of a module which purports to do something like that. I'm sure there are some other ones. http://developmentseed.org/blog/2009/feb/05/extendr-flickr-and-views is an interesting case study of something similar as well.

That being said, it's probably not a simple task.

0

If you want views to access your XML data, you would need to store it in a database. All that views really does, is to create SQL for you, and provide some different theming functions for outputting the data.

There are some modules that can help you with this. Since you have custom data, the data module is probably the best fit. This would keep the data in a custom table.

You could create a cron job, to delete entries older than x hours/days to make sure you don't store the data permanently. It's a bit cleaner this way and the best option I can think of.

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.