<EndTest 
Title="CommandLineTest" 
TUID="" 
Result="Fail" 
Repro="" CA="909962792" LA="910146700" >
  <rti id="3805221601" />
  <ctx id="3065565191" />
</EndTest>数据格式都是这样的 我想得到的是
<EndTest 
Title="CommandLineTest" 
TUID="" 
Result="Fail" 
Repro="" CA="909962792" LA="910146700" >
</EndTest>
怎么匹配  
  <rti id="3805221601" />
  <ctx id="3065565191" />
中的ID是不一样的<EndTest 
Title="CommandLineTest" 
TUID="" 
Result="Fail" 
Repro="" CA="909962792" LA="910146700" >
</EndTest>
中的属性也是不一样的

解决方案 »

  1.   

    <EndTest Title="\S*?" TUID="\S*?" Result="\S*?" Repro="\S*?" CA="\d*?" LA="\d*?" >([\s\S]*?)</EndTest>
      

  2.   

                        int newCount;
                        int i;
                        newCount = LBoxURL.Items.Count;
                        for (i = 0; i < newCount; i++)
                        {
                            XPathDocument xpDoc = new XPathDocument(LBoxURL.Items[i].ToString());
                            XPathNavigator xpNav = ((IXPathNavigable)xpDoc).CreateNavigator();
                            string xmlPath = "/" + textBox2.Text + "[@" + textBox3.Text + "]";//设定获取对应接点的路径,修改如有修改在这就可以
                            XPathNodeIterator xpIter = xpNav.Select(xmlPath);
                            while (xpIter.MoveNext())
                            {
                                XPathNodeIterator newIter = xpIter.Current.SelectDescendants(XPathNodeType.All, true);
                                int a = newIter.Count;
                                if (a == 3)
                                {
                                    ++a;
                                    while (newIter.MoveNext())
                                    {
                                        if (a != 2 && a != 3)
                                        {
                                            //string con = newIter.Current.InnerXml.ToString();
                                            string content = newIter.Current.OuterXml;
     /********************************************************************************************
                                            content 就是获取的字符串我怎么把那段正则放进去?
    *********************************************************************************************/
                                            textBox1.AppendText(content + "\r\n");
                                        }
                                        --a;
                                    }
                                }
                            }
                            /*保存到txt文件*/
                            StreamWriter SWriter = new StreamWriter(txtAddress.Text + "\\" + this.txtTitle.Text);//写入地址
                            SWriter.Write(textBox1.Text);//内容
                            SWriter.Close();
                        }
                        /*end*/
                        MessageBox.Show("保存成功!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("出错" + ex.ToString());
                    }
      

  3.   

    百度一下Regex.Replace,结合我给的表达式,把组1替换为空就可以了。