0

My question is : How to deserialize unknown XML to C# classes ? I know about "Paste special -> Paste XML as Classes" but i need something (code )which generate a C# classes object from XML. My program need add, remove and edit all nodes in tree XML.

Błażej Rejnowski
  • 239
  • 1
  • 2
  • 8
  • try to use xsd.exe [link](https://msdn.microsoft.com/en-us/library/x6c1kb0s.aspx) – Keppy Sep 26 '16 at 09:15
  • check this. http://stackoverflow.com/questions/13704752/deserialize-xml-to-object-using-dynamic – Shakti saxena Sep 26 '16 at 09:24
  • Keppy I dont want to use xsd.exe , i want to deserialize unknown XML to C# classes by my program, i dont want to use outside program to do this, Shakti in your link we know about xml structure – Błażej Rejnowski Sep 26 '16 at 09:43

1 Answers1

0

You can do this by using XDocument, parsing the XML, outputting a C# CodeDom into memory, compiling it in memory. Not sure why you would want to do such a thing, but XML Parsing and CodeDom is the way to go to.

PhillipH
  • 6,182
  • 1
  • 15
  • 25
  • I provided an answer to "but i need something (code )which generate a C# classes object from XML" and " i want to deserialize unknown XML to C# classes by my program". Your other requirement "My program need add, remove and edit all nodes in tree XML" doesn't make any sense in the context of generating C# classes. I presume you are trying to write an XML editor of some kind ? In which case generating C# classes is not really relevant to your goal. – PhillipH Sep 26 '16 at 10:11
  • No. This forum is for solving specific technical problems with code. I'm afraid you will have to start doing some googling for ".net XML Editor". Perhaps https://xmlwebpad.codeplex.com/ might be a good start point. – PhillipH Sep 26 '16 at 11:38