How to combine multiple xml files with different schema to one csv file

CJoeS 0 Reputation points
2025-02-25T13:40:03.2433333+00:00

I have 33 xml files with different schema to convert to one csv file.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,317 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiale Xue - MSFT 49,051 Reputation points Microsoft Vendor
    2025-02-26T02:57:05.7066667+00:00

    Hi @CJoeS , Welcome to Microsoft Q&A,

    You need to read each XML file separately. Extract relevant data based on the unique schema of each file. Convert the extracted data to a common format suitable for CSV files. Merge the extracted and normalized data into a structured format. Save the merged data to a CSV file.

    Different XML files may contain different fields (column names), resulting in inconsistent CSV structures. You need to dynamically create CSV column headers. For example: UserID and RecordID are unified as ID.

    If a field is missing in the XML, fill it with a default value (such as "" or N/A).

    It is recommended to fix the data structure and use a class (POCO) as the model for CSV records. Only take the data that is common to each XML.

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.