Quote:
Originally Posted by Brujah
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'
|
i actually timed it, the preg match is faster