Displaying namespaced XML data in Drupal views

Submitted by Darren Oh on Fri, 08/07/2020 - 15:53

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

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">

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

Further reading

XML Path Language (XPath), Version 1.0