aa

by goya on February 11th, 2012
No notes
Syntax: PHP
Show lines - Hide lines - Show in textbox - Download
<?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();
?>

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS