首页 > 代码库 > 获取xml中所有某标签的内容

获取xml中所有某标签的内容

string regStr = "<A>([\\w\\W]+?)</A>";//匹配A标签正则表达式
Regex tmpReg = new Regex(regStr, RegexOptions.Compiled);
MatchCollection matcheList = tmpReg.Matches(xml);
if (matcheList.Count != 0)
{
 for (int i = 0; i < matcheList.Count; i++)
  {
       list.Add(matcheList[i].Groups[0].Value);
  }
}

 

获取xml中所有某标签的内容