Latest web development tutorials

PHP asXML () function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Examples

Formatting XML (version 1.0) of the SimpleXML object data:

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

Running instance »

Definition and Usage

asXML () function data format XML (version 1.0) of the SimpleXML object.


grammar

asXML( filename );

参数 描述
filename 可选。规定需要写入数据的文件的名称。

technical details

return value: If successful, it returns a string if it fails it returns FALSE. If you specify a filename argument, if successful returns TRUE, on failure returns FALSE.
PHP version: 5.0.1+


PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual