2

I have a myXML.xml file. I used xsd.exe to generate and myXMLClass.cs class files which contains many partial classes.

Now, I want to use this myXMLClass.cs class and retrieve all the nodes/attributes/values/data using my original myXML.XML file. But, how can I do this because of myXMLClass.cs has so many partial classes?

eg. I want to do deserializing using TypeOf myXMLClass like like this. But, myXMLClass contains many partial classes.

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.

CB4
  • 690
  • 3
  • 13
  • 25
  • 1
    Only thing you have to do is according to your XML structure arrange your class structure and then XML Serialize will deserialize it. if you can share your XML I will be able to give you the answer. check this link http://stackoverflow.com/questions/364253/how-to-deserialize-xml-document – Seminda Dec 05 '16 at 23:55
  • so what is the point of using sxd.exe to generate the .cs file from xml file? can we not use the .cs file directly? Because my xml is quite large and complicated. – CB4 Dec 06 '16 at 14:10
  • actually my code is correct. it works. I just can't seem to get the data for tags like these – CB4 Dec 06 '16 at 19:41
  • 1
    You can use XmlAttribute attribute to get those attribute values.http://stackoverflow.com/questions/11182162/c-sharp-add-an-xml-attribute-using-object-xmlserializer – Seminda Dec 07 '16 at 00:05
  • @Seminda can you take a look at my other question thanks http://stackoverflow.com/questions/41021366/how-to-deal-with-the-xmlns-headers-when-deserializing – CB4 Dec 07 '16 at 15:57

1 Answers1

0

I ended up ditching the XSD.EXE generated .CS class.

I decided to make my own object class which resemble the XML schema and it works.

@Seminda Thank you for the suggestion.

CB4
  • 690
  • 3
  • 13
  • 25