How to Convert CSV to XML in Excel: 4 Methods

Method 1 – Opening CSV File in Excel

  • Open the CSV file in Excel.
  • Note down the heading of each column. This will be required to create the XML template.
  • For my dataset, they are the Name and Location columns.

Convert CSV to XML in Excel


Method 2 – Creating XML Template in Notepad

  • Create a new template file with the extension .xml and open the file using any text editor.
  • Type the following XML code in the text editor.
  • Replace the words Name and Location with your own column headers.
  • Change the words location_data and location to suit your dataset.

Convert CSV to XML in Excel


Method 3 – Importing Template into Excel

  • Go to the Developer tab and under the XML section click on Source.

convert csv to xml in excel

 

  • Open the XML Source window, and click on XML Maps.

Convert CSV to XML in Excel

  • In the new XML Maps window, click Add.

Convert CSV to XML in Excel

  • In the Select XML Source window, select All Files from the File Types drop-down.
  • Select the XML template file that you created and click Open.

Convert CSV to XML in Excel

  • In the new message box, click OK.

Convert CSV to XML in Excel

  • In the new window, you will see that Excel has added the template file as an XML map.
  • Press OK.

  • The column headers appear as a tree structure in the window XML Source.

  • From the XML Source window, click and drag the Name section to cell B4, where the column header is.
  • Drag and drop the Location section to cell C4.

  • Excel will map the dataset and format it as shown below.


Method 4 – Exporting File in XML Format

  • Navigate to the Developer tab, and from the XML section, click on Export.

Convert CSV to XML in Excel

  • AfIn the new Export XML window, give the file a name and click on Export.

Convert CSV to XML in Excel

  • Excel will export and save the file in XML format, and you can open it to check if the operation was successful.


Download Practice Workbook

You can download the practice workbook from here.


Related Articles

<< Go Back to Export Excel to XML | Export Data from Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Nazmul Hossain Shovon
Nazmul Hossain Shovon

Nazmul Hossain Shovon, a BUET graduate in Naval Architecture and Marine Engineering, embarked on his career with 8 months dedicated to the Exceldemy project's triumph. Transitioning into a Software Developer role, he specialized in web add-in development. At Exceldemy, he authored about 125 blog articles and solved many visitors’ problems, refining his writing skills and delving into Excel-related topics. With a primary passion for programming and software development, Shovon continually explores new horizons, fostering professional growth in his... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo