Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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??

  • *Experts*
Posted

I haven't tried this, but when you load the XML into the DataSet I assume you're 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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

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 don't want that either!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...