PHP asXML() Function

The asXML method formats the parent object's data in XML version 1.0.

public mixed SimpleXMLElement::asXML ([ string $filename ] )

The asXML() function returns a well-formed XML string (XML version 1.0) from a SimpleXML object.

Example -

ParameterDescription
filenameIf specified, the function writes the data to the file rather than returning it.

If the filename isn't specified, this function returns a string on success and FALSE on error. If the parameter is specified, it returns TRUE if the file was written successfully and FALSE otherwise.