• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

C# datatable to XML

Mercypoint

Weaksauce
Joined
Oct 22, 2005
Messages
74
I'm wondering if there is an easier way then what I am doing right now.

Currently, I have a XSD and a database table. The XSD is pretty nested but the table is very flat. I need to have a way to "map" the fields of the database table so I can easily export the the rows of data into XML.

I have tried xsd.exe to create a strongly-typed dataset but the XSD is too complex that the SDK tool can't handle some of the nesting. So I am forced to write the xml via stringbuilder or xmltextwriter.

There has to be a better way to do this then to recursive through all the records.

any ideas?
 
I saw the term "DataTable" in the post's title, and first thought of the ReadXML() and WriteXML() methods of a DataSet object. So if you have an actual DataTable object, then load it as the first table in a DataSet object, and use those methods as needed.

If not, then please clarify.
 
I use 'datatable' because the database view that is provided to me is just that, one table. In reality, the data source is coming from many many different databases.

Because of the complexity of the XSD, I can not simply do a writeXML. From my understanding, writeXML will simply write a XML file that has the exact structure as the view. Unfortunately, the XSD is heavy in "complexType" and the view is very flat so some mapping is required. I guess it is a lot like converting an Excel (flat) dataset to Object orientated.
 
Back
Top