Question

Each time i do

$country = $this->dom->saveXML(); // put string in country 
$this->dom->save('country.xml');

It delets the old country.xml and creates a new country.xml how can i append the old content of country.xml to the new content and save it again as country.xml

Was it helpful?

Solution

Rather than trying to append it to the file, have you considered appending the new data to the existing 'old' DOM and then saving that to country.xml? This way will keep the document consistent and valid.

OTHER TIPS

If I understand correctly then you want to append the new XML to the end of the old file? This is a bit unusual for XML, however you could do it simply by writing to the file using

file_put_contents('country.xml', $country, FILE_APPEND);

rather than

$this->dom->save('country.xml');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top