Reading XML Rows and Workbooks
Select logical sheets, stream row elements, infer scalar types, and control header and column behavior.
Updated
Xml::read()sheetNames()projectColumns()rows()What you will learn
- Read a simple root containing repeated row elements.
- Select named logical sheets from workbook-style XML.
- Control scalar inference, trimming, null conversion, and limits.
Read repeated row elements#
$rows = Xml::read('orders.xml', [
'row_tag' => 'order',
'infer_types' => true,
'trim_values' => true,
'empty_strings_to_null' => true,
'max_depth' => 32,
])->withHeaderRow(1)->streaming()->rows();Read logical sheets#
$session = Xml::read('workbook.xml', [
'sheet_tag' => 'sheet',
'row_tag' => 'row',
]);
print_r($session->sheetNames());
$orders = $session->sheet('Orders')->withHeaderRow(1)->rows();Pin column order during streaming#
$rows = Xml::read('events.xml', [
'row_tag' => 'event',
'xml_columns' => ['id', 'type', 'created_at'],
'streaming_extra_keys' => 'error',
'include_header_row' => true,
])->withHeaderRow(1)->rows();Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue