简体   繁体   中英

PHP How to build repairing Stream Wrapper

我需要修复即时从互联网上传入的XML文档的一部分,这意味着我正在使用流,迫不及待要加载整个文档,因为文件太大了,我没有有这么多时间:)所以我考虑使用流包装器,但是我有点卡住了如何实现它,实际上我没有找到实现stream_read()的线索-Methods ....可以你帮我吗?

As far as you're looking for some example code for a Stream-Wrapper class, see Example class registered as stream wrapper .

As you have not shared much about the nature of the fixes you want to apply on the streamed data, it's hard to provide more information.

Maybe a stream filter is something less complex which does the job as well for you. And based on your comments this looks more appropriate as you do not want to care about providing the stream but working with it. See the manual page for stream_filter_register() which has an example on how to filter the stream on the fly.

As you have not shared what actually is broken and as XML is a file-format that needs to be fully loaded into memory to deal with it correctly (strictly spoken), I can not say if a stream filter really is appropriate or not.

Strictly spoken: It might not be technically possible what you try to achieve because of the nature of XML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM