Try :
$url = 'somelink.com';
$result = file_get_contents($url);
$dom = new DOMDocument;
$dom->loadHTML($result);
$classname="jobtitle";
$finder = new DomXPath($dom);
$spaner = $finder->query("//*[contains(@class, '$classname')]");
Or if you don't want to use XPath traversal, you can simply loop throught all the div nodes and get the class attribute that is equal to "jobtitle".
This is the code:
$url = 'somelink.com';
$result = file_get_contents($url);
$dom = new DOMDocument;
$dom->loadHTML($result);
$nodes = $dom->getElementsByTagName ("div");
$wanted_node ;
foreach( $nodes $n) {
if ($n->getAttribute('class') == "jobtitle"){
$wanted_node = $n;
}
}
//If wanted_node is not null(the node with class=jobtitle is found
if (isset ($wanted_node)){
echo $wanted_node;
}
parse()function and tell us what does not work as expected - actual vs. expected outcome. And let us know in detail what you've tried to debug your code. Please read How to Ask