Thursday, October 27, 2005

php - getFirstOrderedNode

I'm kicking off my code snippet series with a php function which mimics javascript's "first ordered node" xpath result type. This series isn't really for my regular readers (if i had any) more for the archives.


function getFirstOrderedNode($xpath, $query, $parent){
$children = $xpath->query($query, $parent);
if($children->length != 1){ return null; }
$child = $children->item(0);
return $child;
}

Tags: ,,,

0 comments: