Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

C#: XML to object @ runtime

Back to Forum: Tech Off
  • User profile image
    Oggelito

    Okey, this isn't your everyday XML question. What I want is; given a xml file - generate some kind of CIL code and instantiate a object of that class and then populate it (deserialize).

     

    I don't want to use a xsd schema and I need to do everything runtime.

     

    Any suggestions, I know how to create a .cs file during runtime. But is that the only way? Then I have to compile it runtime as well. Is that even recommended Smiley ?


    Might annoy some people but I want to have it as easy as possible. The xml object will populate a data form of some kind, if you want to know.

     

    Love any input!

     

     

     

  • User profile image
    W3bbo

    I can't think of any problem where this kind of convulted object serialisation would be a solution.

     

    If you can you provide further details of the original problem I'm sure we forum go-ers can come up with a better solution.

  • User profile image
    ManipUni

    You could write the object when you compile your application, import the XML using a normal XML reader, populate an instance of the object and then write out the entire object using a binary write?

     

    The benefit of this method is that you can keep your XML import code outside of the object you would store making it smaller. The drawbacks are that it is a horrible design and binary writes are the devil.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.