private static Regex regex = new Regex("<(\\w+?)[ >]", RegexOptions.Compiled); 
private string GetRootElement(string body)
{
    Match match = regex.Match(body);
        if (match.Success)
        {
            return match.Groups[1].ToString();
        }
        else
        {
            throw new TopException("Invalid XML response format!");
        }
}

 

相关文章: