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

ParameterIs RequiredDescription
filenameOptional.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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions