日期:2014-05-18 浏览次数:20822 次
static void Main(string[] args)
{
string str = @"<?xml version='1.0' encoding='utf-8'?><Response><BusinessNo>1234567890</BusinessNo><MessageCode>-100</MessageCode></Response>";
Regex re = new Regex(@"<\?xml\s* version='1.0'\s*encoding='utf-8'\?><Response><BusinessNo>([^<]+)</BusinessNo><MessageCode>([^<]+)</MessageCode></Response>", RegexOptions.None);
Match ma = re.Match(str);
Console.WriteLine(ma.Groups[1].Value); //1234567890
Console.WriteLine(ma.Groups[2].Value); //-100
Console.ReadLine();
}