Choosing what a row is
A table needs one row per record, but XML does not say which element is the record. The converter decides in this order:
- The document element is skipped.
<catalog>or<urlset>is the container, not a record. - Its repeated child is the row:
<url>for a sitemap,<book>for a catalog. - If the rows sit deeper, it looks inside the single wrapper.
<rss><channel>is passed to reach the repeated<item>, and<response><data><items><item>works the same way. - If there is only one record, you get one row.
A note names the element it picked and lists what it left out. For an RSS feed it says that channel.title and channel.link are not in the table, because the title belongs to the feed, not to an item. If the choice is wrong, open More options and type a path under Rows come from, for example channel.item or data.row. A single dot makes the whole document one row.
Attributes, nested tags and repeats
Each child element and each attribute becomes a column. <book id="b1"><title>A</title></book> gives the columns @id and title. The @ keeps an attribute apart from a child element of the same name. Choose name under XML attributes to drop it.
Nested elements are joined with a dot: <author><first>X</first><last>Y</last></author> gives author.first and author.last. An attribute on a nested element gives names such as link.@href, as in Atom feeds.
A tag that repeats inside a record, such as two <genre> elements, becomes genre.0 and genre.1. Under Lists inside a record you can join them into one cell, g1;g2, or keep them as JSON text. XML cannot tell a list of one from a single value, so when a tag repeats in some records but appears once in others, it is written as a list in every row, and a note says so. That keeps the columns lined up.
Records can have different tags. The columns are all the names found, in order of first appearance, and a record without one gets an empty cell.
Opening the result in a spreadsheet
- Delimiter. Excel uses the list separator of the computer's regional settings, a semicolon in many European countries. If everything lands in one column, choose a semicolon under Delimiter in the output.
- Accents. Feeds are full of accents and symbols. Turn on Add a byte order mark under More options so Excel reads the file as UTF-8.
- Formulas. Excel runs cells that start with = + - or @ as formulas. Turn on Protect against spreadsheet formulas if the XML comes from people you do not know.
What a table cannot hold
- One kind of record at a time. If the XML holds customers and orders, one table is made from the list that repeats most. Type the other path under Rows come from and convert again.
- Mixed content. Text between tags is merged into one value and loses its position.
- Comments, processing instructions and the DOCTYPE are dropped.
- Namespaces. Prefixes stay in the column names, as in
ns:price, unless you turn on Remove namespace prefixes under More options.