I am trying to find a reusable way of taking a CSV file and generating an XML file from it that conforms to a specified XSD. I haven\'t really found a reusable approach for
Well, I don't really have a ready-made, out-of-the-box solution for this, but maybe:
read your CSV file with a library like FileHelphers; for this, you need to create a class MyDataType which describes the columns in the CSV, and you get an array of MyDataType
if you decorate that class with the proper XML serialization attributes like [XmlIgnore], [XmlAttribute] and so forth, you might be able to just simply serialize out the resulting array of MyDataType into an XML that conforms to your XML schema
or if that doesn't work, you could create another class that maps to your XML requirements (generate it from the XSD you have), and just simply define a mapping between the two types MyDataType (from your CSV) and MyXmlDataType (for your XML) with something like AutoMapper
It's not boiler-plate - but fairly close, and you could possibly make that pretty much a "framework" to just simply plug in your own types (if you need to do this frequently).