MNB PHPExcelDeveloper Guide

XML · Structured output

XML structured output examples.

Package-local, copy-ready examples organized like the classes and methods reference. Open one example at a time, search by method, and jump from the right-side index.

Packagemnb/mnb-phpexcel-xml:^2.0Reference1 examples · 2 methods
XML individual library

Structured output examples with copy-ready, production-minded PHP.

Every snippet uses mnb/mnb-phpexcel-xml or its declared Core dependency. Each copied snippet includes strict typing, a concise summary, implementation guidance, readable limits, and a safe fixture check.

1
examples
2
documented methods
Example 01

Return structured XML from a read session

Open related guide
toStructuredXml()saveStructuredXml()
return-structured-xml-from-a-read-session.php
<?php

declare(strict_types=1);

/*
Summary:
    Serialize workbook-aware row counts, warnings, and source metadata as XML.

Implementation note:
    Structured XML keeps the same summary and warning model as other Core-backed readers.
*/

use Mnb\PHPExcel\Format\Xml;

$xml = Xml::read(__DIR__ . '/report.xml', [
    'row_tag' => 'row',
])->withHeaderRow(1)->toStructuredXml(
    readOptions: ['preserve_original_row_numbers' => true],
    xmlOptions: ['pretty' => true]
);

header('Content-Type: application/xml; charset=UTF-8');
echo $xml;