from_xml() walks a node path and hands each match to the pipeline; xpath() picks values out of
the node.
Examples
Reading
Description
Documentation
Readers are extractors: they yield Rows and describe the schema they produce.
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__ . '/data/orders.xml')
->withXMLNodePath('rows/row')
)
->withColumn('id', ref('node')->xpath('order_id')->domElementValue())
->withColumn('created_at', ref('node')->xpath('created_at')->domElementValue())
->withColumn('discount', ref('node')->xpath('discount')->domElementValue())
->drop('node')
->limit(3)
->collect()
->write(to_output(truncate: false))
->run();