简体   繁体   English

使用xsd.exe gernerated .cs文件将XML反序列化为对象

[英]deserialize XML into object using the xsd.exe gernerated .cs file

I have a myXML.xml file. 我有一个myXML.xml文件。 I used xsd.exe to generate and myXMLClass.cs class files which contains many partial classes. 我使用xsd.exe生成包含许多分部类的myXMLClass.cs类文件。

Now, I want to use this myXMLClass.cs class and retrieve all the nodes/attributes/values/data using my original myXML.XML file. 现在,我想使用这个myXMLClass.cs类,并使用我原来的myXML.XML文件检索所有节点/属性/值/数据。 But, how can I do this because of myXMLClass.cs has so many partial classes? 但是,我怎么能这样做因为myXMLClass.cs有这么多的部分类?

eg. 例如。 I want to do deserializing using TypeOf myXMLClass like like this. 我想像这样使用TypeOf myXMLClass进行反序列化。 But, myXMLClass contains many partial classes. 但是,myXMLClass包含许多部分类。

XmlSerializer serializer = new XmlSerializer(typeof(myXMLClass??));

Thank you 谢谢

Update: 更新:

Also, I am having problem with obtaining the "code" and "description" of this tag that has this kind of setup. 此外,我在获取具有此类设置的此标记的“代码”和“描述”时遇到问题。

<HitCode code="4" description="CONSUMER DECLARATION" />

Again, my goal is to retrieve "code" and "description" of this tage. 同样,我的目标是检索此标准的“代码”和“描述”。

I ended up ditching the XSD.EXE generated .CS class. 我最终放弃了生成.CS类的XSD.EXE。

I decided to make my own object class which resemble the XML schema and it works. 我决定创建自己的类似XML模式的对象类,它可以工作。

@Seminda Thank you for the suggestion. @Seminda感谢您的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM