Add field to configure attributes for root element, so it is possible to configure XML like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
  <!-- rows -->
</urlset>

Comments

Bobík created an issue.

philsward’s picture

I'll +1 this. Need something similar for google shopping. Otherwise you have to muck with the template file.

My recommendation is to make it a generic text field to allow "any" attribute. For example, google shopping doesn't require a urlset:

<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
Shiraz Dindar’s picture

well it's 2 years later but I'm +1'ing this too. The root node would setting as it is now would work fine for this if it wasn't run through _views_data_export_xml_tag_clean, so it would be pretty easy option to add beside it, like a "leave root node unfiltered" checkbox.

As it is now, it's the view header template you want to edit, for anyone looking.

stefan.butura’s picture

This worked for me:

function MY_MODULE_preprocess_views_data_export_xml_header(&$variables) {
  $view = $variables['view'];
  if ($view->name == 'VIEW_NAME' && $view->current_display == 'DISPLAY_ID') {
    $variables['root_node'] .= ' xmlns:g="http://base.google.com/ns/1.0" xmlns="http://www.w3.org/2005/Atom"';
  }
}

function MY_MODULE_preprocess_views_data_export_xml_body(&$variables) {
  $view = $variables['view'];
  if ($view->name == 'VIEW_NAME' && $view->current_display == 'DISPLAY_ID') {
    foreach ($variables['xml_tag'] as &$tag) {
      $tag = 'g:' . $tag;
    }
  }
}