MNB PHPExcelDeveloper Guide
XML library

Standalone XML Library

Install and use the standalone XML library for secure forward-only reading, schema mapping, and configurable XML output.

Updated

LevelAll levelsReading time6 minPackagemnb/mnb-phpexcel-xml
Xml::read()Xml::write()XmlSchemaMapping::from()XmlWriter::payloadToString()

What you will learn

  • Install the standalone XML library and understand its secure defaults.
  • Read simple row XML or map external schemas into canonical columns.
  • Write row or workbook XML with configurable element names.

Install the XML package#

Terminal
composer require mnb/mnb-phpexcel-xml:^2.0

ext-xmlreader is recommended for native streaming. The package includes a portable XML reader fallback through Core.

Read and write the default row shape#

read-xml.php
use Mnb\PHPExcel\Format\Xml;

$rows = Xml::read('customers.xml', [
    'row_tag' => 'customer',
])->withHeaderRow(1)->rows();

Secure parser defaults#

  • External network access is disabled through non-network parser flags.
  • Document type declarations are rejected unless allow_doctype is explicitly enabled.
  • File size, row count, and nesting depth can be bounded.
  • Element names emitted by the writer are sanitized into valid XML tags.