Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5974411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:56:23+00:00 2026-05-22T20:56:23+00:00

I have a code as such that reads in an xml file into a

  • 0

I have a code as such that reads in an xml file into a dataset, then displays the data in a datagridview.
I have done some googling and I have found that my dataset reads in the xml, but only on the first “level” of elements.

It doesn’t reach in far enough for the complex types. However it does save the complex types, or the “in-line” data, into the next table in the dataset. The xml file is all in one dataset, but the tables are split up depending on the complex types of the elements.

Is there any way to combine the tables into one big table so that I don’t need to have a numeric up and down value to switch between table views?

For my program, I’m trying to make it easier for the user to be able to manipulate these xml files. Having one big table would be far better than a bunch of smaller ones.

Here is the code:

    string filename = Address.Text;
    dataGridView1.AutoGenerateColumns = true;
    DataSet dataSet1 = new DataSet("DEFAULT");
    dataSet1.ReadXml(filename, XmlReadMode.Auto);
    bindingSource1.DataSource = dataSet1.Tables[(int)tablenumber.value].DefaultView;
    dataGridView1.DataSource = bindingSource1;
    richTextBox1.Text = filename + " loaded.";
    label2.Text = "File Open: " + filename;

and so on, but the tablenumber would be 0 to start off with. This is just the “first” table that the dataset has when it reads in the xml file. Also, I do have a schema that goes with the xml files. Would I need to read the schema as well just so it knows that there’s a complex type and will read according to the schema?

(.NET 3.5 SP1, Visual Studio 2008 C#)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:56:23+00:00Added an answer on May 22, 2026 at 8:56 pm

    This question was solved by using a for loop that iterated through each table in the dataset and merging it. This produced a larger datatable that suits the datagridview regardless of the schema. There were void cells, which is expected, but that was exactly what I wanted: a huge datatable.

        DataTable dt = new DataTable();
        dt = dataSet1.Tables[0];
        int i;
        for(i = 1; i < dataSet1.Tables.Count; i++)
        {
            dt.Merge(dataSet.Tables[i]);
        }
    

    Was the code I used. =)

    Edit: More information (restrictions, example) Table Merge

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been given some XML files that don't quite have a proper schema (I
I have the following piece of code which replaces template markers such as %POST_TITLE%
I have code that references a web service, and I'd like the address of
I have code that looks like the following, which works fine for displaying the
To load XML files with arbitrary encoding I have the following code: Encoding encoding;
Hi I have a script that creates a file and stores it on the
I've got a requirement to take some XML and transform it into a fixed-width
i have a file that looks like this: TTITLE0=track name 1 TTITLE1=track name 2
I have code to create another row (div with inputs) on a button click.
I have code similar to this filtering entries in an Array of Objects: var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.