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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
Okay thanks guys, I'm going with the XmlTextWriter.
b1xml2 gets the poinx.
b1xml2 gets the poinx.
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