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

Posted on 2007-10-18
Last Modified: 2010-04-15
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.
Question by:dentyne
    1 Comment
    LVL 22

    Accepted Solution

    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.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    WiX Installer 2 41
    return array from dll 13 21
    WMI, model #, retrieving information 10 59
    Explain Unit of Work pattern 2 29
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now