You are here

function ViewsDataExportExporterXML::add_row in Views data export 7.4

Add a single row to the export file.

Parameters

$file_handle: A PHP file handle to the export file.

array $data: An array of formatted data for this row. One cell per item.

int $row_count: The current number of rows in the export file.

$field_titles:

Overrides ViewsDataExportExporter::add_row

File

exporters/views_data_export_exporter_xml.inc, line 186

Class

ViewsDataExportExporterXML
Webform exporter for creating XML files.

Code

function add_row(&$file_handle, $data, $row_count, $field_titles) {

  // Set up an XMLWriter object.
  $writer = new XMLWriter();
  $writer
    ->openMemory();
  $writer
    ->setIndent(TRUE);
  $writer
    ->setIndentString("  ");

  // Get bof() to write the bof to our writer.
  $null_file = NULL;
  $this
    ->bof($null_file, $writer);
  $writer
    ->writeElement('bluff', 'content');

  // Clear out its contents, to leave it blank but at the right indentation.
  $writer
    ->flush();

  // Open the item tag.
  $writer
    ->startElement($this->options['item_node']);

  // Get the row contents as XML.
  $this
    ->array_to_xml($writer, $data, $file_handle, $field_titles);

  // Close the item tag.
  $writer
    ->endElement();

  // Write the XMLWriter contents to the provided file.
  $output = $writer
    ->outputMemory(TRUE);

  // Remove the extra indentation-correcting tag from the start.

  //$output = preg_replace('/<' . $this->options['root_node'] . ">\n/", '', $output, 1);
  fwrite($file_handle, $output);
}