The following code can be usefull to search a string with in an html tag
private string ParseHtml(string strInput, string key)
{
string returnValue = string.Empty;
int startIndex = strInput.ToUpper().IndexOf("<" + key.ToUpper() + ">");
int endIndex = strInput.ToUpper().IndexOf("</" + key.ToUpper() + ">");
if(startIndex != -1 && endIndex != -1)
{
returnValue = strInput.Substring(startIndex + (key.Length + 2), endIndex - (startIndex + (key.Length + 2))).ToString();
}
return returnValue;
}
string str = "<from>jeebu@abc.com</from>";
MessageBox.Show(ParseHtml(str ,"from"));
will return jeebu@abc.com
No comments:
Post a Comment