XML 序列化,在本例中为 IXmlSerialized 或属性
我之前做过一些 XML 序列化,但我使用了属性,我不确定这对于我的下一个作业是否可行,这里是 XML 操作要求的简短列表。
- 通用 XMl 操作,绑定到树视图,无模式。
- 加载/保存 XML。
- 加载/保存属性以及值(我相信该术语是元素文本?),并注意节点的名称。
- 可以安全地忽略注释,就像文档信息标记(即 UTF-8 和模式标签)一样。
关于如何最好地处理这个问题有什么建议吗?
I've done some XML serialization before but i used Attributes, I'm not sure this is doable for my next assignment, here's a brief list of XML manip requirementes.
- General Purpose XMl manipulation, tied to a treeview, no schema.
- Load/Save XML.
- Load/Save Attributes as well as Values (i believe the term is Element Text?), and be mindful of the Node's name.
- Comments can be safely ignored as can Document info markup (ie, the UTF-8 and schema tags)
Any suggestions on how best to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可能不会为对象模型和 IXmlSerialized 烦恼 - 听起来您不妨用
XmlElement
/XmlDocument
来讨论- 即,将数据作为 xml 块传递。 由于您没有模式,因此将其撕碎是没有意义的; 您也可以通过 xml DOM 来完成。当你说树视图时——这是winforms、asp.net、wpf吗? 我相信 asp.net 树视图可以获取 xml 源,但对于 winforms,您必须自己迭代节点。
I probably wouldn't bother with an object model and
IXmlSerializable
- it sounds like you might just as well talk in terms of anXmlElement
/XmlDocument
- i.e. pass the data around as a block of xml. Since you have no schema it would be pointless to shred it out; you might as well do it via an xml DOM.When you say treeview - is this winforms, asp.net, wpf? I believe the asp.net treeview can take an xml source, but for winforms you'd have to iterate the nodes yourself.
不知道“之前但我使用了属性”到底是什么意思,但我也推荐 XmlSerializer:
Don't know what exactly you mean with "before but i used Attributes" but I would recommend XmlSerializer too:
我建议您使用 .NET 框架支持的简单 XML 序列化。
浏览这些 MSDN 文档
如何序列化对象
如何反序列化对象
I would suggest you to use the simple XML serialization supported by the .NET framework.
Go through these MSDN documentation
How to Serialize an object
How to Deserialize an object