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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
XMLReaderorXML Parser), and for writing there isXMLWriterwhich 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.