Search code examples
asp.net-mvc-2linq-to-xmllinq-to-xsd

How to get data from XML files into business objects?


I need to build a view in my MVC 2 application that allows a user to upload an XML file. The XML files will conform to an XSD. I need to parse the XML and extract data to populate C# objects that will then be sent off to a web service.

My question is...since I know the exact "format" of the XML files, because of the XSD, is there some easier way to "move" the data in the XML files into my business objects?

I read about some Linq-to-XSD project, but it appears to have been abandoned. Linq-to-XML doesn't seen very helpful, since I still have to "walk" through the entire XML document to get all the data.

Surely there is an easier way?


Solution

  • http://linqtoxsd.codeplex.com/

    here is a linq to xsd project on codeplex

    http://www.codeproject.com/KB/linq/LINQ_to_XSD.aspx

    another on code project

    http://www.hanselman.com/blog/LINQToEverythingLINQToXSDAddsMoreLINQiness.aspx

    and scott hanselmen talks about this. Between these links(no pun intended) you should be alright