locked
Question about DatSet.WriteXML RRS feed

  • Question

  • Folks

     

    I am trying to write a dataset into XML. However the XML created has only the Non Empty Columns in it. I need to capture all columns (even NULLS in the database) in the XML(As empty Nodes). Requirement of a 3rd party service we are integrating with).

     

    Any clues whether this can be achieved through Dataset.WriteXML ?

     

    Thanks

     

    Sid

    Tuesday, May 6, 2008 5:19 PM

Answers

  • When you persist DatasSet into XML you could specify to persist not only data, but also structure (schema) of the DataSet. In this case loading part on other side can restore all the information including NULL values. Idea with the DataSet persister is not to store NULL values and skip them to reduce size of XML and at same time to show that it is NULL, so I would say it is good design on DataSet side. If you persist schema information (I believe it is WriteSchema option for the WriteXml method), then other side could load DataSet based on that structure, then data will be loaded for the values that are not NULL and rest of the values will automatically get NULLs.

     

    Wednesday, May 7, 2008 9:59 AM

All replies

  • What if you replace NULLs with an empty string in the dataset before you call the WriteXml method?
    Tuesday, May 6, 2008 9:26 PM
  • When you persist DatasSet into XML you could specify to persist not only data, but also structure (schema) of the DataSet. In this case loading part on other side can restore all the information including NULL values. Idea with the DataSet persister is not to store NULL values and skip them to reduce size of XML and at same time to show that it is NULL, so I would say it is good design on DataSet side. If you persist schema information (I believe it is WriteSchema option for the WriteXml method), then other side could load DataSet based on that structure, then data will be loaded for the values that are not NULL and rest of the values will automatically get NULLs.

     

    Wednesday, May 7, 2008 9:59 AM