0

我在 xml 的不同属性值下有不同的 xml 节点可用。我想执行 xml 中各个属性值下存在的各个节点。但是我面临一个问题,每次我能够识别和更改属性值,但始终执行第一个属性值下可用的节点。请找到我的代码如下:

try
            {
                XmlDocument XDoc = new DrWatsonCore().LoadXMLFromFile(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile);
                XmlNodeList Update_Bugs = XDoc.GetElementsByTagName("Bugs");


                string attrVal_TestCondition = "";
                string attrVal_Name = "";

                for (int m = 0; m < 10; m++)
                {
                    attrVal_TestCondition = Update_Bugs[m].Attributes["TestCondition"].Value;
                    attrVal_Name = Update_Bugs[m].Attributes["Name"].Value;

                    foreach (string AttValue in attrVal_TestCondition.Split(','))
                    {
                         //Step1: Create Bugs
                        List<string> BugWSResponseList1 = new List<string>();
                        Logger.Write("\n\n" + DateTime.Now + " : " + " : START : Creation of a set of Bugs via bug.Add API");
                        BugWSResponseList1 = CreateBugs(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile, DateTimeStamp);

请找到如下示例 xml,其中我在TestConditionas下有两个不同的属性值可用STATESTATUS而当我的循环带来第二个属性值时,'STATUS'在我的情况下,可用的 xml 节点STATE正在执行。这实际上是我的问题。请建议.

<DrWatson>
  <Bugs Name="Testing 11" TestCondition="STATE">
    <Bug>
      <family>ESG</family>
      <product>Dr.Watson</product>
      <version>Xpress API</version>
      <productarea>1</productarea>
      <subarea>Blank</subarea>
      <title>Bug.AddNote#1 : Dr.Watson Framework by Aman</title>
      <description>test</description>
      <appLanguages>English~~Bug</appLanguages>
      <platforms>Win XP All~~English~~Bug</platforms>
      <state>Open</state>
      <status>NeedsReview</status>
      <reason>Blank</reason>
      <failureType>Unspecified</failureType>
      <Frequency>Unknown</Frequency>
      <severity>0</severity>
      <priority>0</priority>
      <methodFound>Blank</methodFound>
      <foundInBuild>1</foundInBuild>
      <dev>bansal</dev>
      <qe>sdawar</qe>
      <keyword>Blank</keyword>
      <duplicateId>Blank</duplicateId>
      <note></note>
    </Bug>
    <Bug>
      <family>ESG</family>
      <product>Dr.Watson</product>
      <version>Xpress API</version>
      <productarea>1</productarea>
      <subarea>Blank</subarea>
      <title>Bug.AddNote#1 : Dr.Watson Framework by Aman</title>
      <description>test</description>
      <appLanguages>English~~Bug</appLanguages>
      <platforms>Win XP All~~English~~Bug</platforms>
      <state>Open</state>
      <status>ToFix</status>
      <reason>Blank</reason>
      <failureType>Unspecified</failureType>
      <Frequency>Unknown</Frequency>
      <severity>0</severity>
      <priority>0</priority>
      <methodFound>Blank</methodFound>
      <foundInBuild>1</foundInBuild>
      <dev>bansal</dev>
      <qe>sdawar</qe>
      <keyword>Blank</keyword>
      <duplicateId>Blank</duplicateId>
      <note></note>
    </Bug>
  </Bugs>
  <Bugs Name="Testing 22" TestCondition="STATUS">
    <Bug>
      <family>ESG</family>
      <product>Dr.Watson</product>
      <version>Xpress API</version>
      <productarea>1</productarea>
      <subarea>Blank</subarea>
      <title>Bug.AddNote#1 : Dr.Watson Framework by Aman</title>
      <description>test</description>
      <appLanguages>English~~Bug</appLanguages>
      <platforms>Win XP All~~English~~Bug</platforms>
      <state>Open</state>
      <status>NeedsReview</status>
      <reason>Blank</reason>
      <failureType>Unspecified</failureType>
      <Frequency>Unknown</Frequency>
      <severity>0</severity>
      <priority>0</priority>
      <methodFound>Blank</methodFound>
      <foundInBuild>1</foundInBuild>
      <dev>bansal</dev>
      <qe>sdawar</qe>
      <keyword>Blank</keyword>
      <duplicateId>Blank</duplicateId>
      <note></note>
    </Bug>
    <Bug>
      <family>ESG</family>
      <product>Dr.Watson</product>
      <version>Xpress API</version>
      <productarea>1</productarea>
      <subarea>Blank</subarea>
      <title>Bug.AddNote#1 : Dr.Watson Framework by Aman</title>
      <description>test</description>
      <appLanguages>English~~Bug</appLanguages>
      <platforms>Win XP All~~English~~Bug</platforms>
      <state>Open</state>
      <status>ToFix</status>
      <reason>Blank</reason>
      <failureType>Unspecified</failureType>
      <Frequency>Unknown</Frequency>
      <severity>0</severity>
      <priority>0</priority>
      <methodFound>Blank</methodFound>
      <foundInBuild>1</foundInBuild>
      <dev>bansal</dev>
      <qe>sdawar</qe>
      <keyword>Blank</keyword>
      <duplicateId>Blank</duplicateId>
      <note></note>
    </Bug>
  </Bugs>
</DrWatson>

我正在使用以下代码部分创建一些错误:

 BugWSResponseList1 = CreateBugs(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile, DateTimeStamp);

请注意,当在获取 xml 中存在的第二个属性值(在我的情况下)之后处理这部分代码时,它会执行属于第一个属性值STATUS的同一组节点,即在我的 xml 中。<Bug><Bug>STATE

4

0 回答 0