Same file, five converters, five tables
We ran the sample above (two customers, one of them with two contacts) through the five converters on Google's first page. We got five different tables back, and not one converter told us which element it had used as the row.
| Converter | Rows | The two contacts | Attributes | Comma in a name |
|---|---|---|---|---|
| This converter | 2 | Numbered columns, or a row each if you pick it | Kept | Quoted |
| A | 2 | Numbered columns | Kept | Quoted |
| B | 3 | Second contact on its own, nearly empty row | Kept | Quoted |
| C | 1 | Both customers squeezed into one row | Kept | Quoted |
| D | 2 | The text [object Object] | type and currency lost | Quoted |
| E | 6 | Rows that mix the two customers | All lost | Comma name not quoted |
Four of the five lost or misplaced data, and you'd only find out in the spreadsheet. Or after the import.
Numbered columns or one row per child
The tool starts with numbered columns, so you get exactly one row per customer in this sample. Every column name is the path to its value in the XML: @ marks an attribute (a detail written inside a tag), and a number in brackets says which of the repeated elements it came from.
<customer id="000184">@id000184<name>nameHarbor Dental, LLCfirst <contact type="billing">contact[1]/@typebillingits <email>contact[1]/emailap@harbor.examplesecond <contact>'s <email>contact[2]/emaillee@harbor.example<balance currency="USD">balance/@currencyUSD
Pick "One row per <contact>" in the Repeated elements menu and each contact gets its own row instead, with the customer's other values copied onto it. Here's the sample both ways, cut down to four columns:
Numbered columns: 2 rows
| @id | contact[1]/email | contact[2]/email | balance |
|---|---|---|---|
| 000184 | ap@harbor.example | lee@harbor.example | 1250.50 |
| 000731 | billing@lakeview.example | 0 |
One row per contact: 3 rows
| @id | balance | contact/@type | contact/email |
|---|---|---|---|
| 000184 | 1250.50 | billing | ap@harbor.example |
| 000184 | 1250.50 | owner | lee@harbor.example |
| 000731 | 0 | billing | billing@lakeview.example |
Use numbered columns when each row has to be one customer, like a customer import into a CRM. Use one row per child when the child is what you're loading or counting: contacts, order lines, invoice items. Don't sum the balance column in the second table, though. It repeats on every contact row.
How the converter decides
- The row is the outermost element that repeats. In an export of orders that each hold order lines, the rows start as orders, not lines. Want one row per line? Pick it in the Row element menu.
- Values stay as written. 000184 stays 000184 and 1250.50 stays 1250.50. Only the indentation around a value is trimmed. Text in a CDATA section (a block marked as plain text) is read as is, and codes like & become the characters they stand for.
- Empty elements still get a column. An empty
<note/>becomes an empty cell. Namespace prefixes stay in the column names. Comments are skipped. - Commas inside a value don't shift your columns. A value with a comma, a double quote or a line break goes in double quotes, the way RFC 4180 describes, so "Harbor Dental, LLC" stays one cell.
- Broken XML gets a line number. If a tag isn't closed, the error says which line and column to look at. Files can be up to 50 MB.
Excel can still change your numbers. Open the CSV there and, by default, 000184 becomes 184 and 07030 becomes 7030. The steps on our JSON to CSV page keep the zeros.
Questions
- Is XML a CSV?
- No. XML is a tree: elements inside elements, with attributes on the tags. A CSV is a grid of rows and columns with nothing nested.
- What happens to attributes?
- Every attribute inside a row gets its own column. Attributes on the elements above the rows, like <export system="billing">, are left out, and the tool tells you which ones.
The CSV is the easy part
An XML export from an old system is often every record it has, dumped as is. Getting it into a CSV takes a minute. Deciding which of those columns go where in your product takes much longer. That's data mapping.
For Rubie's customers, 95% of the systems they move from don't have a clean API or export that captures all the data needed. When that file comes from a new customer leaving another system, Rubie does the whole move. It gets the data out, including what the export missed, and loads it into your product without engineering time. Go-live doesn't wait on the data. See how Migration Playbooks run a migration end to end.