php getElementsByTagName with nodeValue returns evil characters
-
29-05-2021 - |
質問
I have some utf-8 html like this:
<a href="http://example.com">Today 11:12 AM</a>
And getElementsByTagName('a')->item(0)->nodeValue
returns this:
Today 11:12 AM
I am not having any problems with other nodes in this html.
What am I doing wrong?
解決 2
Source documents are ASP and IIS.
I ended up using this for the offending characters:
str_replace( chr(), chr(), $html);
他のヒント
try to explicitly set the encoding for the DOMDocument Object:
$dom = new DOMDocument('1.0', 'UTF-8');
所属していません StackOverflow