runnerjp Posted October 16, 2014 Share Posted October 16, 2014 I have been able to pull the html of a given node <td class="winner"> <a href="/jockey/497-g-lee">G Lee</a><br><em><a href="/trainer/3372-r-varian">R Varian </a></em> </td> what im trying to do is pull the text if href contains jockey (in this case the result will be G Lee).im doing this by doing the following @$dom2->loadHTML($trainer);$xpath2 = new DOMXPath($dom2);//chekc to see if it had html in it? $result_rows2 = $xpath2->query('//a[contains(@href, "jockey")]'); note trainer is just the html posted above.now i do a var_dump on the data and get this: object(DOMNodeList)#12 (1) { ["length"]=> int(1) } object(DOMNodeList)#13 (1) { ["length"]=> int(1) } object(DOMNodeList)#12 (1) { ["length"]=> int(1) } object(DOMNodeList)#13 (1) { ["length"]=> int(1) } object(DOMNodeList)#12 (1) { ["length"]=> int(1) } object(DOMNodeList)#13 (1) { ["length"]=> int(1) } object(DOMNodeList)#12 (1) { ["length"]=> int(1) }im not sure why but its not picking up the results?!?!?would anyone be able to assist? Link to comment https://forums.phpfreaks.com/topic/291860-domdocument-unable-to-pull-results-from-href/ Share on other sites More sharing options...
Barand Posted October 16, 2014 Share Posted October 16, 2014 you could try simple_html_dom include('simple_html_dom.php'); $str = '<td class="winner"> <a href="/jockey/497-g-lee">G Lee</a><br><em><a href="/trainer/3372-r-varian">R Varian </a></em> </td>'; $html = str_get_html($str); $jockey = $html->find("a[href*=jockey]"); echo $jockey[0]; //--> G Lee $trnr = $html->find("a[href*=trainer]"); echo $trnr[0]; //--> R Varian Link to comment https://forums.phpfreaks.com/topic/291860-domdocument-unable-to-pull-results-from-href/#findComment-1493912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.