Displaying namespaced XML data in Drupal views

Submitted by Darren Oh on

The Views XML Backend module allows data from XML documents to be rendered in Drupal views. It uses XPath queries to select rows and fields from XML data. Given
<rss>
  <channel>
    <item/>
  </channel>
</rss>

the XPath query to get all the items within a channel would be /rss/channel/item.

However, if an XML document contains a default namespace, the element names will not work by themselves. Given
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url/>
</urlset>

the XPath query to get all urls would be /*[local-name()='urlset']/*[local-name()='url'].

Further reading

XML Path Language (XPath), Version 1.0