MNB PHPExcelDeveloper Guide
v2.0.5
XML module

XML Module

Read XML rows securely with a forward-only parser, map arbitrary schemas, and write configurable XML output.

Updated

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

What you will learn

  • Install the XML module 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:^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.