我希望你能帮助我返回属性的唯一值。我试过通过谷歌搜索,但并不成功。
我的xml格式如下:
<?xml version="1.0" encoding="utf-8"?>
<threads>
<thread tool="atool" process="aprocess" ewmabias="0.3" />
<thread tool="btool" process="cprocess" ewmabias="0.4" />
<thread tool="atool" process="bprocess" ewmabias="0.9" />
<thread tool="ctool" process="aprocess" ewmabias="0.2" />
</threads>
我希望返回不同的工具和过程属性。我更喜欢使用linq解决方案。
IEnumerable<XElement> singlethread = apcxmlstate.Elements("thread");
我的工具 = 包含不同工具的数组/列表,例如 {atool, btool, ctool}
感谢任何帮助。
var paramColl = apcxmlstate.Elements("thread") .Select(e => e.Attribute(AttName).Value) .Distinct();
。 - Amir Ismail