RosettaCodeData/Task/XML-DOM-serialization/PHP/xml-dom-serialization.php
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

9 lines
406 B
PHP

<?php
$dom = new DOMDocument();//the constructor also takes the version and char-encoding as it's two respective parameters
$dom->formatOutput = true;//format the outputted xml
$root = $dom->createElement('root');
$element = $dom->createElement('element');
$element->appendChild($dom->createTextNode('Some text here'));
$root->appendChild($element);
$dom->appendChild($root);
$xmlstring = $dom->saveXML();