View Full Version : Getting the URL out of TD

07-25-2012, 07:31 PM
I'm using xpath to get stuff out of a html table cell using an query like so:

@$NPRows = $xpath->query( "//html/body/div[3]/div[3]/table/tr/td[2]/table[2]/tr/td/div/div/table/tr[2]/td/table/tr/td[contains( b, 'KP' ) ]" );

I use

foreach ( @$NPRows as $result ){
echo $result->textContent;

to get the text I need out of the <b> tags. there is a <a href> tag in the td as well. In my loop, how to I grab the URL? is there a special xpath command like textContent that is for URLs?

echo $result->GetAttribute ('href');

doesn't return anything :(

07-25-2012, 07:33 PM
15 seconds of googling return this: http://stackoverflow.com/questions/8027323/php-xpath-get-attribute-value