- mb_convert_encoding: documentation ( source)
- libxml_disable_entity_loader: documentation ( source)
- libxml_use_internal_errors: documentation ( source)
<?php
$content = <<<HTML
<div class="directions">
<div class="left">ä,ö,ü</div>
<div class="right">right</div>
</div>
HTML;
libxml_use_internal_errors(true);
libxml_disable_entity_loader(true);
$html = new DOMDocument();
$html->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'));
$xpath = new DOMXpath($html);
$result = $xpath->query('//div[contains(@class, "left")]');
echo $result[0]->textContent;