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

  • SEARCH
  • Home
  • 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 8124757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:34:08+00:00 2026-06-06T06:34:08+00:00

I need to read data from XML to a List<>. The XML file contains

  • 0

I need to read data from XML to a List<>.
The XML file contains three table format
XML:

<?xml version="1.0" standalone="yes"?>
<Test>
  <Table1>
    <Column_tb1>8</Column_tb1>
  </Table1>
  <Table2>
    <Column_tb2_AA>1</Column_tb2_AA>
    <Column_tb2_BB>11</Column_tb2_BB>
  </Table2>
  <Table2>
    <Column_tb2_AA>2</Column_tb2_AA>
    <Column_tb2_BB>22</Column_tb2_BB>
  </Table2>
  <Table3>
    <Column_tb3_AA>2</Column_tb1_AA>
    <Column_tb3_BB>1</Column_tb1_BB>
    <Column_tb3_CC>25</Column_tb1_CC>
  </Table3>
</Test>

Dataset can read that quite simple,

DataSet dsProfile = new DataSet();
dsProfile.ReadXml(strProfile);

By this way three datatables will in dsprofile automatic.
How can use a list as a container to save XML file data?
if only one table format, i can do that:

List<Table1> listtable1 = new List<Table1>();
XmlSerializer serializer = new XmlSerializer(typeof(List<Table1>));
FileStream stream = File.OpenWrite("data.XML");
serializer.Serialize(stream, listtable1);

But there are 3 types of tables in file. What can i do if i still want to use List<>?

Best Regards.

  • 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-06-06T06:34:11+00:00Added an answer on June 6, 2026 at 6:34 am

    I think your approach is not very safe. You can choose to make everything strong-typed and defined by:

    1. Create XSD for the XML file
    2. Use XSD.EXE to generate a serializable class
    3. Use XmlSerializer to deserialize the XML into a class instance
    4. Modify the instance
    5. Use XmlSerializer to serialize back to XML

    Another option is to make a base class for the three derived classes. That way the list can still serialize its contents as their derived types. However, the serializer will then serialize type information.

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

Sidebar

Related Questions

Can I read a XML file from remote server such as http://dealer.somedomain.com/data/inventory.xml I need
I need to read data from a legacy database file produced by Visual Basic
As part of an assignment, I need to read data from a binary file
I need to read the data from a file that can be either comma
I need to read some data from an input file and plot a graph
I need to read small sequences of data from a 3.7 GB file. The
Example: I read data from an XML file. This data has unique id elements.
So I want to read data from an xml file, I am now at
I need to read in XML data posted from external systems, which will be
Hi there I'm use to SQL, but I need to read data from a

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.