-1
我有以下html,我想获取图像“src”的值。我使用的PHP不返回任何东西。我没有得到任何错误,我不确定代码是否错误或发生了什么?从父节点获取img节点
<a class="main-img" href="/product/index.jsp">
<img src="14402813t241x292.jpg" height="292" width="241">
</a>
我试过以下没有成功。
$img = $xpath->query("//img");
$img = $xpath->query("//a[@class='main-img']/img");
$img = $xpath->query("//img/@src");
$img = $xpath->query("//a[@class='main-img']/img/@src");
我试过这个http://ideone.com/5iKXuI,没有运气,但是你的例子很好用 –
当我运行时,它会抛出'PHP注意:未定义的变量:curl_data在/ home/shiplu/src/xpath-image中。在线33上的php。但是输出很多图像路径。请参阅http://ideone.com/sycAzt –