我想读取xml中指定的所有属性值。请在示例xml下面找到如下:
<DrWatson>
<Bugs Name="STATE" TestCondition="STATE">
<Bug>
<family>ESG</family>
<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="STATUS" TestCondition="STATUS">
<Bug>
<family>ESG</family>
<product>Dr.Watson</product>
<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>
<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>
我想一口气阅读下面提到的所有属性Test Condition
。目前我正在尝试使用以下代码执行此操作:
XmlDocument XDoc = new DrWatsonCore().LoadXMLFromFile(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile);
XmlNodeList Update_Bugs = XDoc.GetElementsByTagName("Bugs");
string attrVal_New = "";
int m = 0;
attrVal_New = Update_Bugs[m].Attributes["TestCondition"].Value;
使用此代码后,我只能将一个属性读取为“STATE”,而另一个属性为“STATUS”没有被读取。请建议。