PHP asXML() Function
Description
The asXML() function formats the SimpleXML object's data in XML (version 1.0).
Syntax
PHP asXML() Function has the following syntax.
asXML(filename);
Parameter
Parameter | Is Required | Description |
---|---|---|
filename | Optional. | Name of the file to write the data tod |
Return
Returns a string on success. FALSE on failure.
If the filename parameter is specified, it returns TRUE on success, FALSE on failure.
Example
Format the SimpleXML object's data in XML:
<?php//from ww w. j a va 2s . com
$note=<<<XML
<book>
<name>PHP</name>
<name>Java</name>
</book>
XML;
$xml=new SimpleXMLElement($note);
echo $xml->asXML();
?>
The code above generates the following result.