Generate XML from DataSet

sandrajean

New member
Joined
Mar 27, 2006
Messages
2
I am trying to create an xml file from an untyped dataset but not all of the tags defined in my schema are ending up in my xml file. I need all tags in my xml file even if they are empty.

I am using the SqlDataAdapter to fill my DataSet and I am using ds.WriteXml to create my xml file. I am calling ReadXmlSchema on the DataSet before filling with data.

Any ideas on how I can get all tags to write to my xml file even when no data is returned from my query??
 
I havent tried this, but when you load the XML into the DataSet I assume youre using ReadXml()? Have you tried the param XmlReadMode.InferSchema? I wonder if that would build the schema for you, and fill in any missing data?

-ner
 
Thanks for your suggestion! When I write the xml file I write out the schema and then when I read the xml I am using XmlReadMode.ReadSchema.

I got the tags to write out by calling ISNULL for every column in my query that can return null and I am putting a value of (1 space). The problem I am finding with that is now the xml:space="preserve" attribute is writing out and I dont want that either!!
 
Back
Top