Hi all,
I am new to DOMDocument, I come up this code to extract content from a website:
<?php
$file = file_get_contents('http://bbs.wenxuecity.com/cooking');
$html = new DOMDocument();
$html->loadHtml( $file );
$xpath = new DOMXPath( $html );
//working query, that proofs the DOMXPath object created correctly.
$links = $xpath->query( "//a" );
//not working query, I can't figure out why as the syntax works fine in Firebug
//$links = $xpath->query( "//a[contains(@class,'post')]" );
header('Content-type: text/html; charset=utf-8');
foreach ( $links as $link )
{
echo $link->textContent, "<br />";
}
?>
My question is: the first query works just fine, but the second (commented out) just won't return anything.
Am I missing something here?
Thanks