asXML string output, writing to file , xml string to fileWe have seen how we can create a SimpleXMLElement object. Now we will translate the XML data to a string by using asXML function. Here is the sample code. We have already used our XML data sample file for this.
To write the same string to a file we will change the above code like this.