I’ve been reading these days about deserialization, DOM, LINQ to XML and LINQ to XSD… for a while, but as I am a newbie I don’t really get the whole picture so I’ll try to explain you my scenery:
I fetch an xml from another’s and I’m just trying to display the information that comes with it in an MVC project view.
I don’t really have an xsd so I reckon for deserializing it into an object I’ll have to use XSD tool for creating an scheme, then a class which matches this scheme and then populate this class and use it in a view. I think this can be done just with a sample xml, am I right?
Another option, is to create “my object” and populate it via DOM. I’ve done something similar lately (I posted a question about it) or even try some of the LINQ approaches (I’ve read the LINQ to XSD has been abandoned by Microsoft).
For the simple thing I’m trying to do I would go for the LINQ to XML but to be honest I haven’t understand fully all the differences I’ve read about the advantages and disadvantages of the different approaches so if someone could help me to decide I really appreciate it.
Thanks in advance
I’ll share the XMLManager we use in my current project. It’s really easy to use, you just pass in the Type of the object you want to serialze to and from, like this:
Here’s the implementation (please note you might want to do something in the catch-clauses, I’ve removed what we do there because it’s specific to out implementation):
To pass this information to a view you make a property in the ViewModel of the object you’ve deserialized using the XMLManager, and bind it through XAML.
[Edit] Might as well show the XAML as well: