【发布时间】:2012-08-27 09:44:21
【问题描述】:
我需要从以下获取 href 属性:
<tr>
<td><h2 class="officers"><a href="/finance/stocks/officerProfile?symbol=ABB.N&officerId=232795" class="link">Roger Agnelli</a></h2></td>
<td>53</td>
<td>2002</td>
<td>Non-Executive Member of the Board of Directors</td>
</tr>
我在这里尝试的是
$a = $tr->getElementsByTagName('a');
echo $a->getAttribute('href');
无法获取 href 值。我在哪里失踪??我在这里需要什么,我希望输出 href 链接,然后将该 href 链接解析为“officer id”。
希望我的问题很清楚..帮助我..
【问题讨论】:
-
你会得到什么?
-
未定义方法 DOMNodeList::getAttribute()
标签: php parsing html-parsing