aa
No notes
Syntax:
PHP
<?php function createElement($domObj, $tag_name, $value = NULL, $attributes = NULL) { $element = ($value != NULL ) ? $domObj->createElement($tag_name, $value) : $domObj->createElement($tag_name); if ($attributes != NULL) { foreach ($attributes as $attr => $val) { $element->setAttribute($attr, $val); } } return $element; } $doc = new DOMDocument('1.0', 'utf-8'); $elm = createElement($doc, 'circle', 'bar', array('cx' => '150', 'cy' => '250')); $doc->appendChild($elm); echo $doc->saveXML(); ?>