Does any one know how to extract only div tags with particular class,in PHP?
<div class="abc">
</div>
<div class="def">
</div>
<div class="xyz">
</div>
I need div only with class="abc". How can I implement that?
Does any one know how to extract only div tags with particular class,in PHP?
<div class="abc">
</div>
<div class="def">
</div>
<div class="xyz">
</div>
I need div only with class="abc". How can I implement that?
What you want is: XPath
<?php
$html = new DOMDocument();
@$html->loadHtmlFile('thepage.html');
$xpath = new DOMXPath( $html );
$nodelist = $xpath->query( "//*[contains(@class, 'abc')]" );
foreach ($nodelist as $n){
echo $n->nodeValue."\n";
}
?>
[updated]
Added new xpath query. give that a try.