0
$convertedhtml = urlencode(mb_convert_encoding($htmlcode,'UTF-8',"auto"));
$doc = new DOMDocument();
$doc->loadHTML($convertedhtml);
$xpath = new DOMXpath($doc);
$elements = $xpath->query("//*[@id='detail']/div[1]/h3/text()");
$elements->item(0)->nodeValue;
return ($elements->item(0)->nodeValue);
網站使用gbk編碼。如果我做轉換,它甚至不會顯示任何東西,但如果我不轉換,它不顯示正確的字符。使用XPath編碼的DOMDocument
有什麼想法?據我所知,mb_ *不支持gbk?
http://stackoverflow.com/questions/3265824/php-utf-8-to-gb2312 – Rikesh
@Rikesh GBK UTF,因爲XPath需要它在UTF-8? – CodeGuru