简化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>
使用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 as $obj) {
$clean[] = $obj->nodeValue;
}
$clink = implode(" ",$clean);
var_dump($clink);
返回...
string(0) ""
用Firebug的XPath检查它返回的ID “orderTableSorted:orderTable:10:j_id504”,我需要找到。
在正确的方向上没有任何的帮助深表感谢。