我正在尝试做一些事情,这可能非常简单,所以请多多包涵,我只想将 XML 文件中的属性转换为我的 C# 代码中的字符串。这就是我所拥有的:
XML:
<MonitorResponseRecord Enabled="false" DisplayName="ValveFailureAtCentralPosition">
<ExpressionMonitor>
<AlarmName>Valve_Position_Fault</AlarmName>
<Parameter> Sensor Position = {X}</Parameter>
</ExpressionMonitor>
</MonitorResponseRecord>
<MonitorResponseRecord ... ... ...>
... ...
... ... and so on about 1600 times.
C#:
[Selrializable]
[XmlType("Alarm")]
public class AlarmDefinition
{
public AlarmDefinition() {}
public AlarmDefinition Clone()
{
AlarmDefinition clone = new AlarmDefinition();
clone.DisplayName = DisplayName;
clone.Category = Category;
clone.Color = Color;
clone.Description = Description;
return clone;
}
[XmlAttribute( ??????????? )] public string DisplayName = "";
所以有人知道我在'?????????????'中需要什么 部分?我试过了:
[XmlAttribute("MonitorResponseRecord",AttributeName = "DisplayName")] public string DisplayName = "";