Skip to main content
← All guides

5 min read

XML to Excel: choose which element becomes a row

By Quentin Delepierre, Salesforce Commerce Cloud consultant

An XML file often has several levels of repetition: orders that contain items, products that contain variants. A table has only one kind of row. Choosing the element that becomes a row decides the rest: the number of rows and the columns. Here is how to see the result before paying, and how to change it.

Got your own XML? Drop it in and see it as a table, free and with no account. For an Excel file you can edit and then rebuild into an XML that keeps its structure, a free account is all you need.

Transform a file

Simple Excel table, free with no account, for files up to 1 MB. File that rebuilds into XML: free account, 3 free credits, no credit card.

Download an example result (.xlsx)Example source XML

A table row is an element of the XML

ExcelifyXML turns each occurrence of a chosen element into one table row: that is the row tag. Everything that element contains (text, attributes, sub-elements) becomes columns, and what surrounds it is kept to rebuild the XML.

When the file has several levels of repetition, the choice changes everything. Invented example, with two orders that contain items:

The XML file
<shop>
  <order id="O1">
    <customer>Alice Martin</customer>
    <item sku="A1"><name>Lamp</name><qty>2</qty></item>
    <item sku="B2"><name>Desk</name><qty>1</qty></item>
  </order>
  <order id="O2">
    <customer>Bruno Leroy</customer>
    <item sku="C3"><name>Chair</name><qty>4</qty></item>
  </order>
</shop>
One row per order (order): 2 rows
@id , customer , item[0].@sku , item[0].name , item[0].qty , item[1].@sku , item[1].name , item[1].qty
O1 , Alice Martin , A1 , Lamp , 2 , B2 , Desk , 1
O2 , Bruno Leroy , C3 , Chair , 4 , , ,
One row per item (item): 3 rows
order.@id , @sku , name , qty
O1 , A1 , Lamp , 2
O1 , B2 , Desk , 1
O2 , C3 , Chair , 4

What the choice changes

  • One row per <order>: one row per order, and the items are numbered in columns (item[0], item[1]), as many as the longest order.
  • One row per <item>: one row per item, narrower columns, and the order.@id column tells which order each item comes from.
  • In both cases, the reconstruction gives back the original XML, with its orders and their nested items.
  • The longer the inner lists, the more the inner element pays off as a row: hundreds of variants per product would give hundreds of numbered columns, while Excel stops at 16,384 columns.

The free preview: try before you confirm

  1. Drop your XML file on the Upload page.
  2. The preview shows up (“Free preview”): the element chosen to make a row (for example “One row per <order> element”), the number of rows and columns, and the first rows of the table. No credit is used until you confirm.
  3. If it's not the right row, open “Not the right row?” under the preview and pick another one: the preview updates, still without using a credit.
  4. When the table suits you, confirm with “Transform to CSV — 1 credit”, then choose the Excel file (.xlsx) or the CSV.

Automatic detection

By default, ExcelifyXML looks for the row tag itself: usually the element that repeats highest up in the file and contains several different fields (a <product>, an <order>). With no repeated element, it falls back on the single element that holds the data, on a list of values, or on the whole file. In the example above, it picks <order>.

“Not the right row?”: the choices offered

The panel lists the other tags found in the file (five at most), each with its number of rows and its kind:

  • repeated element: an element that comes back several times with several fields (a product, an order), the most common case;
  • several types: several kinds of elements at the same level (folders and contents, for example); one row per element, and a _type column says which type it is;
  • single element: one element holds all the data; the table has one row;
  • list of values: a list of simple elements; one row per value;
  • whole file: no repetition to use; the whole file is taken as a single row.
  • “Automatic detection”: go back to the original choice, once another tag has been picked;
  • “Another tag”: type the name of a tag of the file (for example product, item, record), then “Preview”.

“One row per X element instead?”

When the preview gives a single row while the file contains a repeated element, it offers it right away: “One row per <item> element instead (3 rows)?”, with a “Preview it” button. And if the table would go over 16,384 columns, Excel's maximum, the preview warns you and suggests narrower row tags.

And to rebuild?

Whatever row you chose, the reconstruction is the same: edit the table, save it, drop it on the Rebuild page (free), and the XML comes back with its original structure.

Drop your XML file and pick your row: the preview is free and needs no account:

Transform a file