将 XML 读入 xsd.exe 生成的类。好主意吗?
我有一个相当复杂的 XML,并且我有它的 XSD。我通过 xsd.exe 生成类,并通过描述的 XmlSerializer 将 XML 读入类结构 此处。
效果很好。然而,这是我第一次这样做,以后我将阅读来自各种来源的大量 XML 文件。这种方法的可靠性如何?是否可以肯定地说,如果 XML 文件符合 XSD 规范,XmlSerializer 将能够很好地读取它?
I have a fairly complex XML coming my way and I have the XSD for it. I generated classes via xsd.exe and read XML into the class structure via the XmlSerializer described here.
It works great. However, this is the first time I've done it this way and I'll be reading in tons of XML files going forward from various sources. How reliable is this method? Could one say with certainty that if the XML file conforms to the XSD specification, that the XmlSerializer will be able to read it in just fine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答:更好。这正是 MSfts Web 服务的工作方式,因此如果您所描述的不起作用,任何 .NET 使用者都会失败,就像您在 .NET 或 Silverlight 中添加对 Web 服务的引用时一样。
Short answer: it's better. This is exactly how MSfts web services work, so if what you described didn't work, any of the .NET consumers would fail, like when you add a reference to a web service in .NET or Silverlight.