我有一个无法更改的格式错误的 HTML。运行 XPath 查询根本不返回节点:
$el = $xpath->query("//a[@class='product']/table"); // can get a tag with "//a[@class='product']"
print_r($el->length); // 0
格式错误的 HTML:
<a class="product" href="#">
<table width="385" cellspacing="0" cellpadding="5" style="border:1px; border-bottom-color:#E2E2E2; border-bottom-style:solid;">
<tr>
<td width="55">
<img src="http://foobar.com:8080/img/1212.jpg" height="50" width="50">
</td>
<td width="195">Cod.27731<br>Product Name</td>
<td width="60" align="center"><a href="?pageContent=items&price=fab&prodcod=27731">Details</a></td>
<td width="80" nowrap>
<div style="color:#FF0000;"><strong>$ 35.23</strong></div>
</td>
</tr>
</table>
</a>
我可以得到 a 元素,但我不能得到它的子元素(表格)......