Question: > 
> **Possible Duplicate:**  
> 
> [How to parse and process HTML with PHP?](https://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php)
> 
> 
> 

Hi there I have scraped a web page

```
  <div class="col blue">
        <img  src="/en/media/Dentalscreenresized.jpg" />
        <h4>This is line i want to scrape</h4>
        <p class="date">12 Sep
            <span class="year">2012</span></p>
        <p>13 people were diagnosed with oral cancer after last year&rsquo;s Mouth Cancer Awareness Day. Ring 021-4901169 to arrange for a free screening on the 19th September.</p>
        <p class="readmore"><a href="/en/news/abcd.html">Read More</a></p>
        <p class="rightreadmore"><a href="http://www.xyz.ie/en/news/">See all News&nbsp;&nbsp;&nbsp;</a></p>
    </div>

```

Now i want to display the `<h4>` tag of `class="col blue"`.I seen online to use `preg_match_all()` I am not familiar with regular expression... any help please

Answer: 
Don't use Regular Expressions to parse HTML. It may seem difficult to use libraries and dedicated solutions. You can find a lot of "Don't use regex" answers out there.

I'd recommend [SimpleHTMLDOM](http://simplehtmldom.sourceforge.net/) which is [simple to use](http://simplehtmldom.sourceforge.net/manual.htm).

```
    <?php
// include necessary classes first.
// e.g. include('simple_html_dom.php'); // assuming the file is in same folder as the php file. Or include it at first or you will get a fatal error.
    $html = str_get_html('<div class="col blue">
            <img  src="/en/media/Dentalscreenresized.jpg" />
            <h4>This is line i want to scrape</h4>
            <p class="date">12 Sep
                <span class="year">2012</span></p>
            <p>13 people were diagnosed with oral cancer after last year&rsquo;s Mouth Cancer Awareness Day. Ring 021-4901169 to arrange for a free screening on the 19th September.</p>
            <p class="readmore"><a href="/en/news/abcd.html">Read More</a></p>
            <p class="rightreadmore"><a href="http://www.xyz.ie/en/news/">See all News&nbsp;&nbsp;&nbsp;</a></p>
        </div>
    ');

    $h4 = $html->find('h4.col.blue');
    ?>

```

Now $h4 contains all elements with the h4 tag with col and blue classes.
Use DOM and Xpath. put your html data in $html.

```
$dom = new DOMDocument('1.0', 'UTF-8');
@$dom->loadHTML($html);
$xmlElements = simplexml_import_dom($dom);

$divs = $xmlElements->xpath("//div[@class='col blue']");
foreach($divs as $div)
{
  $heading = $div->h4;
  var_dump($heading);
}

```

Additional Note: 

```
Don't use regular expressions to parse/scrape info from HTML. Its a Bad technique

```