function repairAmpersands(&$xml)
 {
     $xml = trim($xml);
     $startIndex = -1;
     $processing = true;
     $illegalChar = '&';
     while ($processing) {
         $startIndex = strpos($xml, $illegalChar, $startIndex + 1);
         if ($startIndex !== false) {
             $xml = XMLRepair::evaluateCharacter($xml, $illegalChar, $startIndex + 1);
         } else {
             $processing = false;
         }
     }
     return $xml;
 }