How to Open an XML File in Excel as a Table
By the DataSwitch Pro team · · 4 min read
Quick answer
In Excel for Microsoft 365 or Excel 2016 and later on Windows, go to Data → Get Data → From File → From XML, select the file, pick the table that holds the repeated records in the Navigator, and click Load (or Transform Data to expand nested columns). Alternatively, convert the XML to CSV with an XML to CSV converter and open the CSV — useful for feeds, sitemaps and other record lists.
Product feeds, sitemaps, bank exports and accounting systems often deliver XML. Double-clicking an XML file usually opens it in a browser as a tree of tags, which is hard to filter or total. Excel can turn the repeated records into rows and columns in a few steps.
Method 1: Get Data → From XML (Power Query)
- Open a blank workbook and choose Data → Get Data → From File → From XML.
- Select the XML file. The Navigator lists the tables Power Query found.
- Click the table that contains your records — for a product feed, the one named after the repeated element, such as
productoritem. The preview shows one row per record. - Click Load for a flat result, or Transform Data if some columns show Table and need to be expanded with the two-arrow icon.
- Click Close & Load.
Like other Power Query imports, the result can be refreshed when the XML file changes.
Method 2: File → Open
Excel can also open an .xml file directly via File → Open. It then asks how to open it; As an XML table makes Excel infer a structure (and warns that it is creating a schema). This works for simple, flat files, but nested documents often produce many columns with repeated values. Power Query gives more control.
Method 3: Convert XML to CSV first
When the XML is a list of records and you just want a sheet, converting is often fastest:
- Open the XML to CSV converter and paste the XML or drop the file.
- The repeated element becomes rows; child elements and attributes become columns (nested ones with dot-separated names).
- Download the CSV and open it in Excel — or turn it into a real workbook with CSV to Excel so codes with leading zeros stay as text.
Example: a product feed
feed.xml
<products>
<product sku="00412">
<name>Ceramic mug</name>
<price currency="EUR">12.50</price>
</product>
<product sku="00413">
<name>Glass jar</name>
<price currency="EUR">8.90</price>
</product>
</products>
Resulting table
@sku | name | price.#text | price.@currency
00412 | Ceramic mug | 12.50 | EUR
00413 | Glass jar | 8.90 | EUR
The @ marks values that came from attributes and #text is the text of an element that also has attributes. Rename the columns as you like after importing.
Common problems
- Only one row appears. The import picked the wrong level, such as the root element. In Power Query, choose the table of the repeated element; in a converter, check which element repeats.
- Leading zeros disappear from SKUs or postcodes. Set those columns to Text in Power Query, or see keeping leading zeros in Excel.
- “The XML file is not well-formed”. A tag is not closed, or the file contains an HTML entity such as
. The error gives a line number; fix that line in a text editor. - Prefixed tags such as
g:priceappear as column names. They are namespace prefixes and can be renamed safely. - Very deep nesting. If the XML has several independent lists (orders with items and payments), import each list as its own table, linked by the order ID.
Sitemaps: a quick SEO audit
Converting sitemap.xml gives a list of every URL with its lastmod date. Sort by date to find pages that have not been updated, or compare the list with your analytics to spot pages that get no traffic.
Try it on your own file. Free, private, and processed in your browser.
Frequently asked questions
Can Excel export back to XML?
Yes, but only through an XML map (Developer tab → Source), which needs a schema. For simple exports, saving as CSV and converting is easier.
Does Google Sheets open XML?
Its IMPORTXML function can read XML from a public URL with XPath queries, but there is no import for an XML file on your computer. Convert the file to CSV and import that.
Why are some cells showing “Table”?
Those columns contain nested elements. Click the expand icon in Power Query to turn them into columns or rows.
Is it safe to convert XML online?
With a browser-based converter that does not upload files, the XML never leaves your computer.