views:

44

answers:

1

I have to write a import utility which will import some data held in an xml file. I imagine that I will create a simple DTO object which is the representation of the import data and then write all my code so that it does the import based on this object.

The XML file will be the definition of the transfer format, so I expect that 3rd parties will produce files in the format to be able to import data into the application. The format may also be expanded in the future, to allow import of more types of data.

What I would like is a simply way of getting my object populated with all the import data to process from the XML file.

I was thinking that I could just deserialise the xml file, but am concerned that there might be issues for 3rd parties creating the files without having the DTO object to serialise in the first place. Is this likely to be a problem? What are the other alternatives, preferably which don't involve reading the xml file manually, but obviously that will be the fall back solution.

+1  A: 

If you create a schema that represents the wire-format (XML format in this case) and hand out the schema to the 3rd parties, they can create the object in their native platform. There are many tools for all languages on all different platforms to take a schema and make the object DTO in source code from it.

XSD.EXE is the one for .Net.

if you expect future extensions, make a new schema per extension or use an XSD:ANY element to hold your extensions in the future.

That way you can keep on using the XmlSerializer and make your life easier.

Hope this helps,

Marvin Smit