Extract data from XML files. Supports navigating to specific nodes within the document structure.
UNIFIED DATA PROCESSING FRAMEWORK
composer require flow-php/etl ~0.33.0 Extracts
Read from various data sources.
Transforms
Shape and optimize for your needs.
Loads
Store and secure in one of many available data sinks.
Examples:
Description
Documentation
Code
<?php
declare(strict_types=1);
use function Flow\ETL\Adapter\XML\from_xml;
use function Flow\ETL\DSL\{data_frame, ref, to_output};
require __DIR__ . '/vendor/autoload.php';
data_frame()
->read(
from_xml(__DIR__ . '/input/dataset.xml')
->withXMLNodePath('users/user')
)
->withEntry('id', ref('node')->domElementAttributeValue('id'))
->withEntry('name', ref('node')->xpath('name')->domElementValue())
->withEntry('active', ref('node')->xpath('active')->domElementValue())
->withEntry('email', ref('node')->xpath('email')->domElementValue())
->drop('node')
->collect()
->write(to_output(truncate: false))
->run();