douwei1944 2013-08-29 16:34
浏览 78
已采纳

Xpath查询辅助嵌套锚点href提取

Here is my code:

$text = '<div class="cgus_post"><a href="?p=15055">Hello</a></div>';
$dom = new DomDocument();
$dom->loadHTML($text);
$classname = 'cgus_post';
$finder = new DomXPath($dom);
$nodes = $finder->query('//div[class="cgus_post"]//@href');

I'm trying to get the href text for an anchor link within the div cgus_post. What's wrong with my query?

  • 写回答

2条回答

  • doubian0284 2013-08-29 16:43
    关注

    probably a missing "@"

    '//div[@class="cgus_post"]//@href'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办