Question

I am reading some master data from a third party accounting application which returns XML. My app sends request on a port on which the third party app is listening and receives the response as XML. There are different types of master data which I am reading, like Employee, BankAccount, etc. There are 20-30 different types of masters.

I need to parse the XML and fill the data in .NET objects. I am wondering how can I reduce my coding effort.

I need to design .NET class for each type of master, and then write parsing methods to parse the XML responses and populate the .NET objects. Since there are 20-30 types of masters each having its own set of fields, this looks like too much work for such boilerplate type of code.

Any ideas how I can reduce my coding effort while still getting the benefits of Object Oriented Programming and compile time checking, Intellisense features, etc?

You can assume that the XML follows a certain pattern, like: ...

How will the code know which XML Tag has to be parsed into which method or property of the C# object? Please note that I am not looking for code generators. I want that based on the XML returned, the code should intelligently identify which fields to be populated, as the no. of fields returned in the XML response may vary, and new fields may get introduced in future versions of the third party accounting application.

May be its not possible what I am trying to achieve?

EDIT 1: May be any external mapping information (or may be as an embedded resource) - which XML tag has to be populated into which class property... But how to implement it?

No correct solution

OTHER TIPS

This is not a complete answer, but can use XSD.EXE to create C# classes from XML files. For more information, see this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top