When I try to write UTF-8 Strings into an XML file using DomDocument it actually writes the hexadecimal notation of the string instead of the string itself.
for exam
To the point answer is:
When your function starts, right after you get the content, do this:
$content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
And then start the new document etc. Check this as example:
if ( empty( $content ) ) {
return false;
}
$doc = new DOMDocument('1.0', 'utf-8');
libxml_use_internal_errors(true);
$doc->LoadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
Then do whatever you were intending to do with your code.