PHP and javascript snippets you can copy and paste.

Monday, April 2, 2007

xml_get_attribValue($node, $name, $default)

/**
* Gets the value of an attribute.
*
* @param object $node.
* @param string $name - the name of the attribute.
* @param string $default - the default value to return if attribute not found.
* @return string.
*/

function xml_get_attribValue($node, $name, $default){
if(is_object($node)){
$val = $node->get_attribute($name);
}
else{
$val = $default;
}
return $val;
}

No comments: