diff --git a/src/adapter/etl-adapter-xml/src/Flow/ETL/Adapter/XML/XMLParserExtractor.php b/src/adapter/etl-adapter-xml/src/Flow/ETL/Adapter/XML/XMLParserExtractor.php index 2da9983d5..7c8f64537 100644 --- a/src/adapter/etl-adapter-xml/src/Flow/ETL/Adapter/XML/XMLParserExtractor.php +++ b/src/adapter/etl-adapter-xml/src/Flow/ETL/Adapter/XML/XMLParserExtractor.php @@ -98,11 +98,11 @@ public function extract(FlowContext $context) : \Generator foreach ($this->elements as $element) { if ($shouldPutInputIntoRows) { $rowData = [ - 'node' => $this->createDOMElement($element), + 'node' => $this->createDOMNode($element), '_input_file_uri' => $stream->path()->uri(), ]; } else { - $rowData = ['node' => $this->createDOMElement($element)]; + $rowData = ['node' => $this->createDOMNode($element)]; } $signal = yield array_to_rows($rowData, $context->entryFactory(), $stream->path()->partitions()); @@ -126,11 +126,11 @@ public function extract(FlowContext $context) : \Generator foreach ($this->elements as $element) { if ($shouldPutInputIntoRows) { $rowData = [ - 'node' => $this->createDOMElement($element), + 'node' => $this->createDOMNode($element), '_input_file_uri' => $stream->path()->uri(), ]; } else { - $rowData = ['node' => $this->createDOMElement($element)]; + $rowData = ['node' => $this->createDOMNode($element)]; } $signal = yield array_to_rows([$rowData], $context->entryFactory(), $stream->path()->partitions()); @@ -194,18 +194,12 @@ public function withXMLNodePath(string $xmlNodePath) : self return $this; } - private function createDOMElement(string $xmlString) : \DOMElement + private function createDOMNode(string $xmlString) : \DOMNode { $doc = new \DOMDocument(); $doc->loadXML($xmlString); - $element = $doc->documentElement; - - if ($element === null) { - throw new RuntimeException('Cannot create DOMElement from XML string: ' . $xmlString); - } - - return $element; + return $doc; } private function freeParser() : void