Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从父节点获取img节点_Php_Xpath - Fatal编程技术网

Php 从父节点获取img节点

Php 从父节点获取img节点,php,xpath,Php,Xpath,我有下面的html,我想得到图像“src”值。我使用的php不会返回任何内容。我没有收到任何错误,我也不确定代码是否错误或发生了什么 <a class="main-img" href="/product/index.jsp"> <img src="14402813t241x292.jpg" height="292" width="241"> </a> 您的最后一个XPath很好 //a[@class="main-img"]/img/@src 注意:查

我有下面的html,我想得到图像“src”值。我使用的php不会返回任何内容。我没有收到任何错误,我也不确定代码是否错误或发生了什么

<a class="main-img" href="/product/index.jsp">
  <img src="14402813t241x292.jpg" height="292" width="241">
</a>

您的最后一个XPath很好

//a[@class="main-img"]/img/@src


注意:查询返回一个节点集。因此,需要对其进行迭代以获得所有节点

当我运行时,它在第33行的/home/shiplu/src/xpath-image.PHP中抛出
PHP注意:未定义变量:curl\u数据。但是输出了很多图像路径。看到这个了吗
//a[@class="main-img"]/img/@src