Extracts
Read from various data sources.
Transforms
Shape and optimize for your needs.
Loads
Store and secure in one of many available data sinks.
<?php
declare(strict_types=1);
use function Flow\ETL\Adapter\XML\from_xml;
use function Flow\ETL\DSL\{data_frame, ref, to_stream};
require __DIR__ . '/../../../autoload.php';
data_frame()
->read(from_xml(
__DIR__ . '/input/dataset.xml',
'users/user'
))
->withEntry('id', ref('node')->xpath('@id')->domElementValue())
->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_stream(__DIR__ . '/output.txt', truncate: false))
->run();
Output
+----+---------+--------+---------------------+
| id | name | active | email |
+----+---------+--------+---------------------+
| 1 | Alice | true | alice@example.com |
| 2 | Bob | false | bob@example.com |
| 3 | Charlie | true | charlie@example.com |
| 4 | David | false | david@example.com |
| 5 | Emma | true | emma@example.com |
| 6 | Frank | false | frank@example.com |
| 7 | Grace | true | grace@example.com |
| 8 | Harry | false | harry@example.com |
| 9 | Isla | true | isla@example.com |
| 10 | James | false | james@example.com |
+----+---------+--------+---------------------+
10 rows