In this question it is addressed how to parse large XML documents in PHP using streams, so that the whole document does not have to be put in memory.
However, the XMLReader
class seems not fit for parsing huge text nodes inside an XML document. Since an API I'm using sends base64-encoded files as values of an XML document, together with some metadata, I'm looking for a way to stream those text nodes, rather than returning the value as a string:
<?php
$reader = XMLReader::open($someStream);
// $reader->read() until a node is reached
// The following puts the whole text node in memory, rather than creating a stream
$content = $reader->value;
?>
Is it possible to turn $reader->value
into a stream?