Q:

Regex find every instance of element in html

I'm scraping an html page that has X amount of instances of the element class="page-title" inside a div element id="row-1"
So we have something like:
<div id="row-1">
    <div class="page-title">
        <span><h4><a>text I want to grab</a></h4></span>    
    </div>
</div>    

There could be 1,2,3,10 of these rows. Could anyone help explain how I can grab every instance of the page title if there are multiple rows?

A:

Whatever you do, don't use a regex! HE COMES
Instead, use a parser:
$dom = new DOMDocument();
$dom->loadHTML($your_html_source_here);
$xpath = new DOMXPath($dom);
$nodes = $xpath->query("//*[@id='row-1']/div[@class='page-title']");

