我与PHP的工作,我想从一个网页PHP DOM文档获取节点信息
一切正常获得某些数据直到我到了这个部分:
<a class="cleanthis" href="https://www.web.com" id="1122" rel="#1122" style="display: inline-block;"><strong>the data i want</strong></a>
正如你可以看到,我想数据强劲,但我不能得到它。我只得到空行
代码我使用:
foreach($as as $a) {
if ($a->getAttribute('class') === 'cleanthis') {
$strong = $a->getElementsByTagName('strong');
echo $strong->nodeValue;;
}
也许是从简化成为一个错字,但类是'cleanthis'和你正在寻找'hoverinfo_trigger' – ishegg
我做了一个错字,对不起 –
我会使用风格使文本强..不赞成与标记混合的风格。那么你可以通过ID选择元素例如.. – rmjoia