X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP asXML() Function

PHP SimpleXML Reference PHP SimpleXML Reference

Example

Return a well-formed XML string (XML version 1.0) from a SimpleXML object:

<?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();
?>

Run example »

Definition and Usage

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


Syntax

asXML(filename);

Parameter Description
filename Optional. If specified, the function writes the data to the file, instead of returning the string

Technical Details

Return Value: Returns a string on success. FALSE on failure. If the filename parameter is specified, it returns TRUE on success, FALSE on failure
PHP Version: 5.0.1+


PHP SimpleXML Reference PHP SimpleXML Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook