I'm using the Views XML Backend to pull in data from a URL.

I'd like the user to be able to optionally be able to select a value for a single field and display the record for that selection. For example, if the XML had information for different offices, I'd like to show the user the records for all of the offices, but allow them to pick a specific office from the list to see only the record for that office. The URL can take a query string or POST parameter with the search terms, but I'm fine with letting the search be done by Drupal.

How do I achieve this in a way that leverages Drupal's capabilities, as opposed to doing the filtering in jQuery?

I already have the view created, but I only see exposed filter options I saw were XML: Numeric, XML: Text, and Global: Combine fields filter. What I'm looking for is something like XML: Pick a Value.


2 Answers 2


The Views XML has no idea of the data in your XML. Have you seen this tutorial video from the project page for Views XML Backend.


They create a simple exposed filter for 1 xml "field" in the view that is searchable by a text filter. This is the simplest form of what you want. Using the exact same type of filter you could:

  • use hook_views_preview and change text field to a select list with options. You would build the options for the list by re-processing your XML file and using xpath queries to find the possible values you want in your select list. You'd likely want to cache these results to a drupal cache table.

  • you could also attempt to create your own Views Filter that does this; but thats harder too.


Interesting question ... There is an alternative to what is suggested in the prior answer, consider looking at the Forena module. There is no "need" for coding skills (e.g. in a custom module), only site building skills are required. Though you 'could' use Forena hooks from within your own modules if you'd want.

Forena is typically used for all sorts of reporting about external databases in formats such as Oracle, MS SQL, Postgress, MySQL, etc (basically any PDO compliant database). But it can also be used for reporting about data stored in XML files. Such XML related reporting is actually how I first discovered this module. It supports all sorts of things like XPath queries, report parameters, visualization using thigs like dataTables, etc. Refer to it's Community documentation and/or the docu that comes with the module for many more details.


  • Forena has (quite a few) official releases, which seems to not be the case for the Views XML backend yet ...

  • Using Forena could also address most, if not all, of what's asked for in the question about Pagination using XML Views Backend ...

Disclosure: I'm a co-maintainer of this module,
I hope this does not violate the site's policy on self-promotion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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