• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

How to prevent a DataColumn from being serialized during GetXml()

I have a dataset with a table.  Two of the datacolumns in the table are part of a nested DataRelation.  I don't want to show these two columns when I use the GetXml() method of the dataset however.  I am just using them to establish the correct hierarchy so the XML is nested properly.  Is there a way to prevent these two columns from being serialized?  Thanks.
0
dentyne
Asked:
dentyne
1 Solution
 
JimBrandleyCommented:
I would think you have three options:
1. If you do not need the complete DataTable after the serialization, you could:
yourDataSet.Tables[0].Columns.RemoveAt( offendingIndex );
before you serialize.

2. You can open the XSD and XML files and remove the elemnts you do not want. XSLT would probably be the easiest way.

3. Create a new DataTable that doesn't contain the columns you do not want. Then populate the rows of that DataTable with the rows of the original DataTable, skipping those two columns.

DataSet.GetXml() and DataSet.WriteXml() do not provide options to do what you want.

Jim
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now