A
A
Alexey Nikolaev2015-10-27 00:17:18
PHP
Alexey Nikolaev, 2015-10-27 00:17:18

What is the most efficient way to render the content of an xml file with data replacement?

Goodnight.
The task arose at the request to open a large (from 20mb to infinity) xml file, change some attributes in it and give it as a raw stream for download, without writing anything to the server. While reading with the help of XML Reader, in the process I collect everything as a simple text from scratch, and give it away as one huge variable. But, firstly, this does not seem beautiful to me, and secondly, files can be of unlimited size, and storing all the content collected during streaming reading them in one variable does not seem to me a good option.
What would you do in this situation?..
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadz Goldman, 2015-10-27
@Heian

Remember.
If the size is supposed to be larger than "normal", then we always read and write in blocks!
This is the easiest option. "Complex" - move by offset in the file.
If you are not writing to disk, then the file is placed in memory.
PHP is configured. Those. what will happen when the configuration specifies (for example) 4 mb, and you have a file of 80 mb. Will we swap?
Therefore, we figure out the blocks and do not bathe.
BUT! Well, we give the same in blocks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question