View Single Post
Old 03-08-2012, 08:33 PM  
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
I want to expand on #2 post, so you can see a working example.

Code:
$html = '<h1 class="video-title one two clearfloat">get this</h1>';

$dom = new DOMDocument();

$dom->loadHTML( $html );

$xpath = new DOMXpath( $dom );

$h1 = $xpath->query( '//h1[contains(@class,"video-title")]' );

var_dump( $h1->item(0)->nodeValue );
DOM is so much better for parsing/scraping once you figure out how to use xpath queries. I had to use "contains(@class,"video-title")" in the above query because the class actually contains more than just 'video-title'
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote