public static String resolveEntity(String entName){
  if (entName.startsWith("#")) {
    StringBuilder sb=new StringBuilder();
    if (entName.charAt(1) == 'x') {
      sb.append((char)Integer.parseInt(entName.substring(2),16));
    }
 else {
      sb.append((char)Integer.parseInt(entName.substring(1)));
    }
    return sb.toString();
  }
 else   if (entName.equals("apos")) {
    return "'";
  }
 else   if (entName.equals("quot")) {
    return "\"";
  }
 else   if (entName.equals("gt")) {
    return ">";
  }
 else   if (entName.equals("lt")) {
    return "<";
  }
 else   if (entName.equals("amp")) {
    return "&";
  }
 else {
    return entName;
  }
}

public static String resolveEntity ( String entName ) { if ( entName . startsWith ( "#" ) ) { StringBuilder sb = new StringBuilder ( ) ; if ( entName . charAt ( 1 ) == 'x' ) { sb . append ( ( char ) Integer . parseInt ( entName . substring ( 2 ) , 16 ) ) ; } else { sb . append ( ( char ) Integer . parseInt ( entName . substring ( 1 ) ) ) ; } return sb . toString ( ) ; } else if ( entName . equals ( "apos" ) ) { return "'" ; } else if ( entName . equals ( "quot" ) ) { return "\"" ; } else if ( entName . equals ( "gt" ) ) { return ">" ; } else if ( entName . equals ( "lt" ) ) { return "<" ; } else if ( entName . equals ( "amp" ) ) { return "&" ; } else { return entName ; } }
resolves an entity reference or character reference to its value .
