title: How to avoid php breaking umlaut characters when loading a xml file?
body: <p>I've got an xml to parse with php, that contains some umlaut characters. 
  Every node that contains a string has the string wrapped in a cdata tag, but my problem starts before parsing the xml: when I load the file (I've also tried to print out the contents of the file with file_get_contests, same result), the umlaut characters get broken, so for example ü becomes Ã¼. Running a htmlentities() is futile, as the characters are already broken at that point. The xml encode is utf-8, so I don't know what else to do to avoid this problem. Anyone can help me?</p>
  
  <p>Edit:
  xml sample 'locations.xml':</p>
  
  <pre><code>&lt;?xml  version="1.0" encoding="utf-8"?&gt;
  &lt;locations&gt;
    &lt;location&gt;
      &lt;id&gt;481&lt;/id&gt;
      &lt;city&gt;&lt;![CDATA[Zürich]]&gt;&lt;/city&gt;
    &lt;/location&gt;
  &lt;/locations&gt;
  </code></pre>
  
  <p>php code:</p>
  
  <pre><code>function parseLocations(){
      $xml = new DOMDocument();
  $xml-&gt;load('locations.xml');
  $xml-&gt;preserveWhiteSpace = false;
  $data = array();
      $locations = $xml-&gt;childNodes-&gt;item(0);
      for($i=0; $i&lt;$locations-&gt;childNodes-&gt;length; $i++){
          $location = $locations-&gt;childNodes-&gt;item($i);
          if($location-&gt;nodeName=="location"){
              $tmp = parseVenue($location);
              $data[] = $tmp;
          }
      }
      echo var_export($data, true); 
  }
  
  function parseVenue($location){
      //I need to exclude some of the nodes
      $exclude = array('#text'); 
      $data = array();
      for($i=0; $i&lt;$location-&gt;childNodes-&gt;length; $i++){
          $tag = $location-&gt;childNodes-&gt;item($i);
          if(!in_array($tag-&gt;nodeName, $exclude)){
              $data[$tag-&gt;nodeName] = $tag-&gt;nodeValue;
          }
  
      }
      return $data;
  }
  </code></pre>
  
  <p>echoed output:</p>
  
  <pre><code>array ( 0 =&gt; array ( 'id' =&gt; '481', 'city' =&gt; 'ZÃ¼rich'), ) 
  </code></pre>