html - PHP DOMXPath gives empty string for /@ID -
simplified html
<tr> <td class="orderoverviewanothercolumn">0177-4066356</td> <a name="ordertablesorted:ordertable:10:j_id504" id="ordertablesorted:ordertable:10:j_id504" href="#"> </tr> <tr> <td class="orderoverviewanothercolumn">0177-4066357</td> <a name="ordertablesorted:ordertable:11:j_id504" id="ordertablesorted:ordertable:11:j_id504" href="#"> </tr> <tr> <td class="orderoverviewanothercolumn">0177-4066358</td> <a name="ordertablesorted:ordertable:12:j_id504" id="ordertablesorted:ordertable:12:j_id504" href="#"> </tr> <tr> <td class="orderoverviewanothercolumn">0177-4066359</td> <a name="ordertablesorted:ordertable:13:j_id504" id="ordertablesorted:ordertable:13:j_id504" href="#"> </tr>
using following code in php
libxml_use_internal_errors(true); $doc = new domdocument(); $doc->loadhtmlfile('448713409.html'); $xpath = new domxpath($doc); $vres = $xpath->query(".//*[@id='ordertablesorted:ordertable:tbody_element']/tr[contains(.,'4066356')]//a[contains(@id,':j_id504')]/@id"); foreach ($vres $obj) { $clean[] = $obj->nodevalue; } $clink = implode(" ",$clean); var_dump($clink);
returns...
string(0) ""
using firebug xpath checker returns id "ordertablesorted:ordertable:10:j_id504" need find.
any in right direction appreciated.
xpath case-sensitive language. therefore, id
, id
entirely different things. in html sample, a
elements have attribute id
, none called id
. that's why query not yield results.
lowercase id
@ end of path expression:
//a[contains(@id,':j_id504')]/@id
i doubt firebug returns uppercase id
when in actual html there none.
Comments
Post a Comment