XML · Reading
XML reading 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.
XML individual library
Reading 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.
- 2
- examples
- 6
- documented methods
Xml::read()withHeaderRow()streaming()rows()<?php
declare(strict_types=1);
/*
Summary:
Stream one repeated element type into normalized associative rows.
Implementation note:
The reader uses secure parser defaults. Keep explicit row tags and source limits for external
XML contracts.
*/
use Mnb\PHPExcel\Format\Xml;
$rows = Xml::read(__DIR__ . '/orders.xml', [
'row_tag' => 'order',
'infer_types' => true,
'max_source_rows' => 100_000,
])->withHeaderRow(1)->streaming()->rows();Xml::read()sheetNames()sheet()rows()<?php
declare(strict_types=1);
/*
Summary:
Discover and select a named sheet from workbook-shaped XML.
Implementation note:
Use logical sheets when the XML contract contains multiple named row collections in one
document.
*/
use Mnb\PHPExcel\Format\Xml;
$session = Xml::read(__DIR__ . '/workbook.xml', [
'sheet_tag' => 'sheet',
'sheet_name_attribute' => 'name',
'row_tag' => 'row',
]);
print_r($session->sheetNames());
$orders = $session->sheet('Orders')->withHeaderRow(1)->rows();No matching example found.Try a method name, task, or result.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue