function HandleError($code, $line, $col, $byte_index = 0)
    {
        $sample_size = 80;
        $sample_start = $byte_index - ($sample_size / 2);
        if ($sample_start < 0) {
          $sample_start = 0;
        }
        
        trigger_error('XML Parsing Error at '.$line.':'.$col. (($byte_index != 0)?' (byte index: '.$byte_index.')':''). '. Error '.$code.': '.xml_error_string($code). ' check sample which starts at position '.$sample_start.': html encoded: '.htmlentities(substr($this->xml, $sample_start, $sample_size)). ' (hex: '.bin2hex(substr($this->xml, $sample_start, $sample_size)).', raw: '.(substr($this->xml, $sample_start, $sample_size)).')');
    }