Link to home
Start Free TrialLog in
Avatar of TDSnet
TDSnet

asked on

Custom XML Writer

Hi,

I need to generate an XML file based on data in an ADO.NET DataSet.  I realise the DataSet object has a simple WriteXml() method but I need the XML in a very specific structure.

My question is this:  Is it completely wrong or out of the ordinary to write a custom XML Writing method..?  I mean, for example, a method that iterates through all the data in a DataSet, one row at a time, and writes it to a TextStream with the tags and elements exactly as they are required..?

Is there another way..?

Cheers,
Jack
Avatar of dualsoul
dualsoul

i think the easiest way serizlize DataSet using WriteXml() and then apply XSLT transformation to create the structure you want.

Certanly you can write your custom method to serialize DataSet in yours format, if you have really problems with XSLT.

But i think XSLT will be easier to develop
ASKER CERTIFIED SOLUTION
Avatar of b1xml2
b1xml2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
XSL is easier but way too slow.  Just overload the WriteXML and make your own.  Use XMLTextWriter for fastest access or XMLDocument if you want to save some coding and sacrifice some speed.

You may end up writing a serializer and a deserializer if you need to bring your data back in.  This is not uncommon at all, I usually end up writing several custom serializers in an application.
Avatar of TDSnet

ASKER

Okay thanks guys, I'm going with the XmlTextWriter.

b1xml2 gets the poinx.