用正则表达式取出包含在 <TABLE> </TABLE>中的 <book> </book>和 <teach> </teach>
static void Main(string[] args)
{
string str = "<table> <book> <row xh=/"74/"> <count>1 </count> <price>43.00 </price> </row> <row xh=/"80/"> <count>1 </count> <price>43.00 </price> </row> </book> <teach> <row xh=/"80/"> <count>1 </count> <price>43.00 </price> </row> </teach> </table>";
Regex reg = new Regex(@"<book>(.*?)</book>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
Regex reg1 = new Regex(@"<teach>(.*?)</teach>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(str);
foreach (Match match in matches)
{
Console.WriteLine(match.Groups[1].Value);
}
MatchCollection matches1 = reg1.Matches(str);
foreach (Match match in matches1)
{
Console.WriteLine(match.Groups[1].Value);
}