note 101694 added to class.domxpath

From: Date: Wed, 05 Jan 2011 18:47:20 +0000
Subject: note 101694 added to class.domxpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-175464@lists.php.net to get a copy of this message
I just spent far too much time chasing this one.... When running an xpath query on a table be careful about table internal nodes (ie: <tr></tr>, and <td></td>). If the master <table> tag is missing, then query() (and likely evaluate() also) will return unexpected results. I had a DOMNode with a structure like this: <td> <table></table> <table> <tr> <td></td> </tr> <tr> <td></td> <td></td> </tr> </table> </td> Upon which I was trying to do a relative query (ie: <?php $xpath_obj->query('my/x/path', $relative_node); ?>). But because of the lone outer <td></td> tags, the inner tags were being invalidated, while the nodes were still recognized. Meaning that the following query would work: <?php $xpath_obj->query('*[2]/*[*[2]]', $relative_node); ?> But when replacing any of the "*" tokens with the corresponding (and valid) "table", "tr", or "td" tokens the query would inexplicably break. ---- Server IP: 69.147.83.197 Probable Submitter: 69.64.236.133 ---- Manual Page -- http://www.php.net/manual/en/class.domxpath.php Edit -- https://master.php.net/note/edit/101694 Del: integrated -- https://master.php.net/note/delete/101694/integrated Del: useless -- https://master.php.net/note/delete/101694/useless Del: bad code -- https://master.php.net/note/delete/101694/bad+code Del: spam -- https://master.php.net/note/delete/101694/spam Del: non-english -- https://master.php.net/note/delete/101694/non-english Del: in docs -- https://master.php.net/note/delete/101694/in+docs Del: other reasons-- https://master.php.net/note/delete/101694 Reject -- https://master.php.net/note/reject/101694 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175464) next »