title: How to define the encoding of a retrieved html page (xpath)
body: <p>When retrieving a webpage (which is not my own). XPath returns weird characters. When using</p>
  
  <pre><code>iconv("UTF-8","ISO-8859-1",$xpath_results-&gt;item(0)-&gt;nodeValue)
  </code></pre>
  
  <p>It's all good. However, it's not very neat to have to do this every time. The returned html looks like this:</p>
  
  <blockquote>
    <p>WeekÂ 26Â HuiswerkklasÂ heleÂ week aanvangÂ 13.30Â uur Dinsdag 26 juni
    Vergadering feestcommissie 10.00 uur Lok.9</p>
  </blockquote>
  
  <p>How can I set the correct encoding when loading the webpage instead of doing it every time when exporting.</p>
  
  <p>When looking to similar questions, I've tried the following:</p>
  
  <pre><code>$uitval_document-&gt;loadHTML('&lt;?xml encoding="UTF-8"&gt;'.file_get_contents(BASE_URL_uitval68.$value-&gt;getAttribute('href')));
  </code></pre>
  
  <p>Which did not work of course, because it's HTML and not XML i'm retrieving. In HTML the encoding would go in the head tag. So it would be possible to load the HTML add it to the headtag, and reload it with the correct encoding. But that's not very efficient and quite hackish. Do you guys know a better solution?</p>