如何反序列化XML? [英] How to deserialize XML?

查看:87
本文介绍了如何反序列化XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我试图根据MSDN中的XMLNODES类从XML读取元素。

 I have tried to read elements from XML based on the XMLNODES class in MSDN.

但是在我的办公室都喜欢将xml反序列化为类,然后获取元素。

But at my office all prefers to deserialize xml to class and then get the elements.

使用XML文件的最佳做法是什么?

Whats the best practise to work with XML file?

推荐答案

您应该将XML构造为好像它属于Schema。 有时,创建一个xsd架构文档来描述数据和类型会有所帮助。 生成的XSD架构将引导您为给定的数据对象进行正确的xml序列化。
You should structure your XML as if it belongs to a Schema.  Sometimes it helps to create a xsd schema document to describe the data and the types.  The resulting XSD schema will lead you to the proper xml serialization for a given data object.


这篇关于如何反序列化XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆