Reputation: 2246
I need the get the href attribute from the following:
<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>
what I am trying here is
$a = $tr->getElementsByTagName('a');
echo $a->getAttribute('href');
unable to get the href value.where i am missing?? what i need here i want the href link to be output and after that parse that href link to the 'officer id'.
Hope I am clear with my question.. Help me..
Upvotes: 1
Views: 111
Reputation: 12535
getAttribute
is not a method of DOMNodeList
it's method of: DOMElement
. So you have to do following:
foreach ($a as $element){
var_dump($element->getAttribute('href'));
}
instead of echo $a->getAttribute('href');
.
Upvotes: 1