Re: Pass file handle in XMLReader
| From: | Christoph M. Becker | Date: | Fri, 04 Dec 2020 12:23:39 +0000 |
| Subject: | Re: Pass file handle in XMLReader | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112412@lists.php.net to get a copy of this message | ||
On 02.12.2020 at 18:17, Aimeos | Norbert Sendetzky wrote:
> The XMLReader object only allows a file name in the constructor and the
> open() method. While this is OK most of the time, files stored at cloud
> services not accessible via an URL must be downloaded first. For big
> files (e.g 100MB to 1GB and more), this requires a lot of time and
> resources.
>
> If the XMLReader would be able accept a file handle too, we could pass
> the handle of a stream to the methods and the XMLReader could process
> the XML data on the fly without the need of a local copy.
>
> Is it possible to allow a file handle in the existing methods or is a
> new one required due to type or other constraints like implementation
> difficulties?
>
> The open() method is implemented here:
>
>
>https://github.com/php/php-src/blob/faea5ab837ab6393c8821f85cf8abe2723593e8e/ext/xmlreader/php_xmlreader.c#L835-L887
For clarity, it might be preferable to introduce a new static creation
method for this. The implementation could probably use
xmlReaderForIO()[1], instead of xmlReaderForFile().
[1]
<http://www.xmlsoft.org/html/libxml-xmlreader.html#xmlReaderForIOhttp://www.xmlsoft.org/html/libxml-xmlreader.html#xmlReaderForIO
Regards,
Christoph