PHP asXML()Function
PHP SimpleXML Reference Manual
Examples
Format the data of a SimpleXML object in XML (version 1.0):
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=new SimpleXMLElement($note);
echo $xml->asXML();
?>
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=new SimpleXMLElement($note);
echo $xml->asXML();
?>
Run Example »
Definition and Usage
The asXML() function formats the data of a SimpleXML object in XML (version 1.0).
Syntax
asXML(filename);
| Parameters | Description |
|---|---|
| filename | Optional. Specifies the name of the file to write the data to. |
Technical Details
| Return Value: | Returns a string if successful, or FALSE on failure. If the filenameparameter is specified, returns TRUE on success, FALSE on failure. |
|---|---|
| PHP Version: | 5.0.1+ |
PHP SimpleXML Reference Manual Other Extensions