I have a script to parse for different div's and to remove them from my string. I use utf-8 encoding because there are german special characters in the strings. It works perfectly but there are always faults with quotation marks. Because they are replaced by question marks. For example: „exmaple“ becomes ?example?
Here is my code:
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->encoding = 'utf-8';
$doc->loadhtml(utf8_decode($content));
$xpath = new DOMXPath($doc);
$ns = $xpath->query('//div[@id="amazon-polly-label-tab"]|//div[@id="amazon-polly-play-tab"]|//div[@id="amazon-polly-by-tab"]');
// there can be only one... but anyway
foreach($ns as $node) {
$node->parentNode->removeChild($node);
}
echo $doc->savehtml();
Do you know what I have to change?