public static class HTMLParser
{
public static String EntityNumberToEntityName(String pFraseComEntityNumber)
{
while (pFraseComEntityNumber.Contains("&#"))
{
String vNumber = ObterEntre(pFraseComEntityNumber, "&#", ";");
pFraseComEntityNumber = pFraseComEntityNumber.Replace(vNumber, NumberToName(vNumber));
}
return pFraseComEntityNumber;
}
private static String ObterEntre(String pString, String pInicio, String pFinal)
{
String vRetorno = String.Empty;
int vIndiceInicio = pString.IndexOf(pInicio);
if (vIndiceInicio >= 0)
{
pString = pString.Substring(vIndiceInicio + 1);
int vIndiceFinal = pString.IndexOf(pFinal);
if (vIndiceFinal >= 0)
{
vRetorno = pString.Substring(0, vIndiceFinal);
}
}
return vRetorno;
}
Private static String NumberToName(String pNumber)
{
String vRetorno = String.Empty;
if (pNumber == "#227")
vRetorno = "atilde";
else if (pNumber == "#231")
vRetorno = "ccedil";
/* Outros codes
...
else if (pNumber == "...")
vRetorno = "...";
...
*/
else // Sugestão: se a sua query for com LIKE e se não achar o code que procura, vc pode colocar um percentual para encontrar
vRetorno = "%";
return vRetorno;
}