PHP and javascript snippets you can copy and paste.

Tuesday, April 3, 2007

xml_create_elementWithText($doc, $name, $value)

/**
* Creates an xml element with text.
*
* @param object $doc.
* @param string $name.
* @param string $value.
* @return object.
*/

function xml_create_elementWithText($doc, $name, $value){

$el = $doc->create_element($name);
$textNode = $doc->create_text_node($value);
$el->append_child($textNode);

return $el;

}

No comments: