如何解决使用 XmlSerializer 向 xml 文件添加动态注释
我正在使用 XmlSerializer 序列化 xml 文件。 它工作得很好:
[XmlRoot(ElementName = "Wire"]
public class Wire
{
[XmlElement(ElementName = "Powerrail"]
public string Powerrail { get; set; }
[XmlElement(ElementName = "IdentCon"]
public IdentCon IdentCon { get; set; }
[XmlElement(ElementName = "NameCon"]
public List<NameCon> NameCon { get; set; }
[XmlAttribute(AttributeName = "UId")]
public string UId { get; set; }
}
<Wire UId="62">
<NameCon UId="51" Name="out" />
<NameCon UId="52" Name="in" />
</Wire>
<Wire UId="63">
<IdentCon UId="22" />
<NameCon UId="52" Name="operand" />
</Wire>
<Wire UId="64">
<NameCon UId="52" Name="out" />
<NameCon UId="53" Name="i_xOff1" />
</Wire>
但现在我想在 xml 文件中添加注释,如下所示:
<Wire UId="62"> <!-- Wire from Location 1 -->
<NameCon UId="51" Name="out" />
<NameCon UId="52" Name="in" />
</Wire>
<Wire UId="63"> <!-- Wire from Location 2 -->
<IdentCon UId="22" />
<NameCon UId="52" Name="operand" />
</Wire>
<Wire UId="64"> <!-- Wire from Location 3 -->
<NameCon UId="52" Name="out" />
<NameCon UId="53" Name="i_xOff1" />
</Wire>
我可以使用 XmlSerializer 实现这一点吗? 非常感谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。