note 74380 modified in function.simplexml-element-asXML by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Sep 2009 15:41:28 +0000 |
| Subject: | note 74380 modified in function.simplexml-element-asXML by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160649@lists.php.net to get a copy of this message | ||
One simple way to write out nicely indented XML data is by converting the whole batch to a DOM
document, and using its formatOutput option:
<?php
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$domnode = dom_import_simplexml($some_simplexml_node);
$domnode = $doc->importNode($domnode, true);
$domnode = $doc->appendChild($domnode);
echo $doc->saveXML();
?>
--was--
One simple way to write out nicely indented XML data is by converting the whole batch to a DOM
document, and using its formatOutput option:
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$domnode = dom_import_simplexml($some_simplexml_node);
$domnode = $doc->importNode($domnode, true);
$domnode = $doc->appendChild($domnode);
echo $doc->saveXML();
http://php.net/manual/en/function.simplexml-element-asXML.php