How to Correctly Format an Imported XML File in Excel
Question details
The user needs to correctly format an imported XML file that is currently opening as a single continuous line instead of structured columns in Excel.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Importing an external XML data file into an Excel workbook.
- Observed behavior
- The XML file opens as one long line instead of displaying structured data in separate rows and columns.
Ensure your XML file is completely downloaded and not corrupted. You may also want to open it in a basic text editor like Notepad first to verify its tags are properly closed.
Import and Map via Excel's XML Data Tools
Use Excel's built-in developer tools to properly map XML elements to specific columns based on an XML schema.
Excel requires an XML schema to understand how to separate the elements into rows and columns. By mapping the elements manually, you can force Excel to structure the imported data correctly.
Go to File > Options > Customize Ribbon, and check the 'Developer' box in the right pane.
Navigate to the Developer tab and click 'Source' in the XML group.
Click 'XML Maps...' at the bottom of the task pane, then click 'Add...', and select your XML file. Excel will automatically generate a schema if one does not exist.
Drag and drop the specific XML elements from the task pane directly into the desired column headers on your worksheet.
Right-click any mapped cell, select XML, and then click Import. Choose your XML file again to populate the mapped columns with the structured data.

Apply an XSLT Stylesheet to Transform the XML
If the XML structure doesn't match a compatible schema, use an XSLT stylesheet to transform the raw data into an Excel-friendly format.
Import Structured XML Data Seamlessly with WPS Spreadsheet
WPS Spreadsheet offers powerful data handling features, allowing you to import and structure XML data easily without complex formatting errors or developer configurations.
- 1. Launch WPS Spreadsheet: Open WPS Office and create a new blank spreadsheet.
- 2. Navigate to Data Import: Go to the 'Data' tab on the top ribbon and select 'Import Data'.
- 3. Select the XML File: Browse your local directories for the target XML file and open it.
- 4. Choose the Import Format: When prompted, select the option to import 'As an XML table' to ensure the data is automatically organized into rows and columns.

Frequently Asked Questions
Why does my XML file open as one single line in Excel?
This usually happens when the XML file lacks a strict tabular schema, or when standard line breaks and carriage returns are missing from the raw data. Excel requires an explicit structure or an XML Map to recognize where rows and columns begin and end.
What is an XML Map in Excel?
An XML map is an internal guide created by Excel that links specific XML elements from your file to particular cells or columns in a worksheet. It bridges the gap between hierarchical XML code and flat spreadsheet rows.
Can I convert an XML file directly to an XLSX file?
Yes. Once you have successfully imported the XML data into Excel and it displays correctly in rows and columns, you can simply go to File > Save As and select 'Excel Workbook (*.xlsx)' to save the formatted data permanently.
Does Excel support all types of XML files?
Excel supports well-formed XML data, but it requires the data to be logically structured for a table. Highly nested or non-tabular XML structures may not import cleanly without manual mapping or XSLT transformations.




