所有存在的值都没有被添加到 c# 中的字典中,以下是到目前为止的代码片段:
XmlNodeList Bugs_filter = Bugs.SelectNodes("/criteria/includeFilterSets/filterSet/filter");
if (Bugs_filter != null)
{
foreach (XmlNode BNode in Bugs_filter)
{
string data = BNode.SelectSingleNode("/criteria/includeFilterSets/filterSet/filter/filterName").InnerText;
string aggregate = BNode.SelectSingleNode("/criteria/includeFilterSets/filterSet/filter/value").InnerText;
{
Dict.Add(data,aggregate);
}
}
}
“Bugs_Filter”中总共存在 3 个值,而当它第二次进入循环时,它只获取第一个值。请建议我做错了什么。
请参阅我从中提取值的 XML:
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><criteria><includeFilterSets><filterSet><filter><filterId>42</filterId>
<filterName>PRODUCT_ID</filterName><operator><id>1</id><name>Equals</name></operator><value>1113</value></filter><filter><filterId>41</filterId>
<filterName>FAMILY_ID</filterName><operator><id>1</id><name>Equals</name></operator><value>ESG</value></filter><filter><filterId>3</filterId><filterName>VERSION_NAME</filterName>
<operator><id>1</id><name>Equals</name></operator><value>4.5</value></filter></filterSet></includeFilterSets><excludeFilterSets/><ordering/>
<bugGroupSearchMode>0</bugGroupSearchMode><caseSensitive>true</caseSensitive><entityToSearch><id>1</id><name>BUG</name></entityToSearch></criteria>
请注意,我正在提取 PRODUCT_ID、FAMILY_ID 和 VERSION_NAME。