You are here

function ViewsDataExportExporter::clean_xml_tag in Views data export 7.4

1 call to ViewsDataExportExporter::clean_xml_tag()
ViewsDataExportExporterXML::_clean_tag_from_key in exporters/views_data_export_exporter_xml.inc

File

exporters/views_data_export_exporter.inc, line 93

Class

ViewsDataExportExporter
Base class defining the common methods available to exporters.

Code

function clean_xml_tag($tag) {

  // These characters are not valid at the start of an XML tag:
  $invalid_start_chars = '-.0123456789';

  // Need to trim invalid characters from the start of the string:
  $tag = ltrim($tag, $invalid_start_chars);

  // Need to remove always invalid characters from the tag:
  $tag = strtr($tag, array(
    '>' => '',
    '<' => '',
    '&' => '',
  ));

  // As a last line of defense, if we've stripped out everything, set it to
  // something.
  if (empty($tag)) {
    $tag = 'invalid-tag-name';
  }
  return $tag;
}