private static string getTrimmedTextContent(IElement element)
 {
     string trimmed=StringUtility.trimSpaces(element.getTextContent());
     StringBuilder builder=new StringBuilder();
     bool whitespace=false;
     for(int i=0;i<trimmed.Length;i++){
       char c=trimmed[i];
       if(c==0x09||c==0x0a||c==0x0c||c==0x0d||c==0x20){
     if(!whitespace) {
       builder.Append(' ');
     }
     whitespace=true;
       } else {
     whitespace=false;
     builder.Append(c);
       }
     }
     return builder.ToString();
 }