Question Locked

Map xml to Strong typed object

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I will be getting a xml file from a proxy webservice call. After that, i have to map that xml file to an strong typed object in my web services.I am using c#.

How can i map an xml file to a strong typed object in my web service.

2 replies

by tony hopkinson

Serialize and deserialize will convert from a class to xml and back again.

However you end up very closely coupled. They change the service content....

Also at least in .Net 2 there's a bad memory leak in deserialise.

You have to do a lot of arsing about to get contained classes in.

Personally I'd do it the long way and put LoadFromXML and SaveToXML methods on a class perhaps in an interface , if you have several service responses or expect more or want some verion independance from the provider.

You could also use a class factory approach if the xml content gives you enough to identify which class to create.

This discussion is closed to new replies.