diff --git a/examples/topics/data_source/xml/code.php b/examples/topics/data_source/xml/code.php index 88364a417..54977ac88 100644 --- a/examples/topics/data_source/xml/code.php +++ b/examples/topics/data_source/xml/code.php @@ -12,7 +12,7 @@ __DIR__ . '/input/dataset.xml', 'users/user' )) - ->withEntry('id', ref('node')->xpath('@id')->domElementValue()) + ->withEntry('id', ref('node')->xpath('@id')->domElementAttribute('id')) ->withEntry('name', ref('node')->xpath('name')->domElementValue()) ->withEntry('active', ref('node')->xpath('active')->domElementValue()) ->withEntry('email', ref('node')->xpath('email')->domElementValue()) diff --git a/examples/topics/data_source/xml/output.txt b/examples/topics/data_source/xml/output.txt index d9a9d451d..b7dbc290e 100644 --- a/examples/topics/data_source/xml/output.txt +++ b/examples/topics/data_source/xml/output.txt @@ -1,15 +1,15 @@ +----+---------+--------+---------------------+ | id | name | active | email | +----+---------+--------+---------------------+ -| | Alice | true | alice@example.com | -| | Bob | false | bob@example.com | -| | Charlie | true | charlie@example.com | -| | David | false | david@example.com | -| | Emma | true | emma@example.com | -| | Frank | false | frank@example.com | -| | Grace | true | grace@example.com | -| | Harry | false | harry@example.com | -| | Isla | true | isla@example.com | -| | James | false | james@example.com | +| 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 diff --git a/src/core/etl/src/Flow/ETL/Function/DOMElementAttribute.php b/src/core/etl/src/Flow/ETL/Function/DOMElementAttribute.php index 7de4d55fc..95eb085e3 100644 --- a/src/core/etl/src/Flow/ETL/Function/DOMElementAttribute.php +++ b/src/core/etl/src/Flow/ETL/Function/DOMElementAttribute.php @@ -16,6 +16,10 @@ public function eval(Row $row) : ?string { $value = $this->ref->eval($row); + if ($value instanceof \DOMAttr) { + return $value->nodeValue; + } + if (!$value instanceof \DOMElement) { return null; }