note 61963 rejected from function.domdocument-get-element-by-id by bjori

From: Date: Sun, 04 Mar 2007 22:29:35 +0000
Subject: note 61963 rejected from function.domdocument-get-element-by-id by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124073@lists.php.net to get a copy of this message
Note Submitter: noel at rescommunes dot ca ---- get_element_by_id does not work on my version of php :( This reallyGet_element_by_id function is a easy replacenemt. <?php /** * Get a node by its id 'attribute' value * * The attribute name id has to be spelled lowercase in xml file * * @return node on success and null in failure. * @param string An id to look for. */ function reallyGet_element_by_id( $str_id ){ $node_with_id = null; $xpath = xpath_new_context($this->dom); $xpresult = xpath_eval($xpath, "//@id"); foreach( $xpresult->nodeset as $node ){ if ($node->value == $str_id) return $node->parent_node( ); } return $node_with_id; } ?>

« previous php.notes (#124073) next »