Here's a snippet of code I'm using to remove content from pages:
/**
 * A method to remove unwanted parts of an HTML-page. Can remove elements by 
 * id, tag name and/or class names. 
 *
 * @param string $html The HTML to manipulate
 * @param array $partsToRemove An array of arrays, with the keys specifying 
 * what type of values the array holds. The following keys are used:
 * 'elements' - An array of element ids to remove from the html 
 * 'tags' - An array of tag names to remove from the html
 * 'classNames' - An array of class names. Each tag that contains one of the 
 * class names will be removed from the html.
 *
 * Also, note that descendants of the removed document will also be removed.
 * 
 * @return string The manipulated HTML content
 *
 * @example removeHtmlParts($html, array (
 *  'elements' => array ('headerSection', 'nav', 'footerSection'),
 *  'tags' => array ('form'),
 *  'classNames' => array ('promotion')
 *  ));
 */
--
public function removeHtmlParts ($html, array $toRemove = array())
{
$document = new \DOMDocument('1.0', 'UTF-8');
$document->encoding = 'UTF-8';
// Hack to force DOMDocument to load the HTML using UTF-8.
@$document->loadHTML('<?xml encoding="UTF-8">' . $response->getBody());
$partsToRemove = array ();
if(isset($toRemove['elements']))
{
  $partsToRemove['elements'] = $toRemove['element'];
}
if(isset($toRemove['tags']))
{
  $partsToRemove['tags'] = $toRemove['tags'];
}
if(isset($toRemove['classNames']))
{
  $partsToRemove['classNames'] = $toRemove['classNames'];
}
foreach ($partsToRemove as $type => $content)
{
    if($type == 'elements')
    {
        foreach ($content as $elementId)
        {
            $element = $document->getElementById($elementId);
            if($element)
            {
                $element->parentNode->removeChild($element);
            }
        }
    }
    elseif($type == 'tags')
    {
        foreach($content as $tagName)
        {
            $tags = $document->getElementsByTagName($tagName);
            while($tags->length)
            {
                $tag = $tags->item(0);
                if($tag)
                {
                    $tag->parentNode->removeChild($tag);
                }
            }
        }
    }
    elseif($type == 'classNames')
    {
        foreach ($content as $className)
        {
            $xpath = new \DOMXPath($document);
                    $xpathExpression = sprintf(
                       '//*[contains(@class,"%1")]', 
                       $className
                    ); 
            $domNodeList = $xpath->evaluate($xpathExpression);
            for($i = 0; $i < $domNodeList->length; $i++)
            {
                $node = $domNodeList->item($i);
                if($node && $node->parentNode)
                {
                    $node->parentNode->removeChild($node);
                }
            }
        }
    }
}
return $document->saveHTML();
}
Note:
- This code has not undergone proper unit testing and probably contains bugs in edge cases
- This method should be refactored into a class, and the contents of the method split into separate methods to ease testing.