To just save the XML to a file, go to the Teneff answer.
But if you also want to SimpleXML XML, use SimpleXML (or even better: XMLReader / XMLWriter ).
Of course, you can also use the DOM , but of all the features around it will be the slowest and most memory-consuming.
source share