You are pretty much stuck with reading the entire file into a string variable or an array of strings ([man]file_get_contents/man or [man]file/man, respectively), inserting your new string into that data, then overwriting the file with the modified data. You could also do the same thing by reading the XML file into an object and modifying it with the [man]SimpleXML[/man] functions, then overwriting the file with the modified version via the asXML() method.