• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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