0
我在嘗試使用Xpath學習網頁抓取。下面的代碼工作,但輸出包含不正確的字符,我無法設法得到這個權利。輸出中的字符不正確
例子:
- 輸出:EmÃ¥mejeriet
- 應該如何:Emåmejeriet
PHP代碼:
<?php
// Tried with these parameters but they doesn't make any difference
$html = new DOMDocument('1.0', 'UTF-8');
$html->loadHtmlFile('http://thesite.com/thedoc.html);
$xpath = new DOMXPath($html);
$nodelist = $xpath->query("//table");
foreach ($nodelist as $n) {
echo $n->nodeValue."\n";
}
?>
我能做些什麼來解決這個問題?