Hi,
If I open a XML file in PHP and edit part of it, does PHP load whole XML content then edit part of it then save whole content back to the file?
Hi,
If I open a XML file in PHP and edit part of it, does PHP load whole XML content then edit part of it then save whole content back to the file?
It depends on which XML library you are using, but for most of them: yes, they'll load the entire XML into memory (unless you're using XMLReader
or XML Parser
), and for writing there is XMLWriter
which can output XML in portions which you can manually write to a file, the rest will create the string as a whole and can possibly save that to the file directly, or give you the whole string which you can save to a file yourself.
As for saving to file: there is no way PHP can 'edit' a 'portion' of a file. PHP can append to a file, or rewrite the whole file. There is no mechanism I'm aware of that just edits a portion.