Вы можете использовать этот метод для достижения желаемого.
Вы должны добавить using System.Text.RegularExpressions;
к пространству имен
protected string GetTagText(string source, string tag)
{
var regexStr = string.Format("(?<=<{0}>).*(?=</{0}>)", tag);
Regex regex = new Regex(regexStr, RegexOptions.IgnoreCase);
if (regex.IsMatch(source))
{
return regex.Match(source).Value;
}
return null;
}
Использовать как
GetTagText("<title>test title</title>", "title");
Returnstest title