如何从xml中获取特定的属性值

时间:2013-11-14 06:33:08

标签: c# xml

  <test-case 
       name="Fiserv.QA.NewUI.Settings.ChangeAddressTelephoneNumber.ChangeAddress.Workflow.ChangeAddressTelephoneNumberTests.ChangeAddressFuncationality" 
       executed="True" 
       result="Success" 
       success="True" 
       time="102.315" 
       asserts="14">

我试过这个

 dr[0] = node.SelectSingleNode("properties/property").Attributes["value"].Value;
 dr[1] = node.Attributes["name"].Value;
 dr[2] = node.Attributes["success"].Value;

但是它无法正确找到成功属性值并同时获取其名称。我想获取成功价值。有人可以告诉我吗?

1 个答案:

答案 0 :(得分:1)

xml.Descendants("test-case").Select(e => e.Attribute("success").Value).ToList()

尝试类似上面的内容