How to Convert Nested XML to an Excel Table Using XPath
Flatten product feeds, invoices and exports from XML into Excel: choose the repeating element, map columns with XPath and combine files.

How to Convert Nested XML to an Excel Table Using XPath
XML files are trees, while spreadsheets are grids, and most of the frustration of converting one to the other comes from that mismatch. A product feed has categories that contain products that contain prices, stock per warehouse and a list of tags. Which of those should become a row? This guide walks through the decisions with the XML to Excel Converter, which lets you answer them with XPath, the standard language for pointing at parts of an XML document.
Step one: decide what a row is
Every useful table starts with one question: one row per what? In a catalogue it is usually one row per product; in an invoice file, one row per invoice line; in a GPS track, one row per track point. The converter scans your file and lists elements that repeat, with how often they occur and how many fields sit below them. The most promising candidate is proposed automatically, but you can pick another or type your own row path.
A little XPath goes a long way
XPath reads like a folder path. /catalog/category/product means product elements inside category elements inside the catalog root. A double slash means at any depth, so //product finds products wherever they are. An at sign selects an attribute, such as @sku. Square brackets add a condition: //product[@status='active'] keeps only active products, //product[price>100] keeps the expensive ones, and item[1] picks the first item. Two dots step up to the parent element. These few pieces cover nearly every conversion.
Step two: choose the columns
Column paths are read relative to the row element. For a product row, name gives the product name, price/@currency the currency attribute of the price, and stock/warehouse the stock figures. The converter lists every attribute and value it found below the first row, and clicking one adds it as a column with a readable name. Values from the surrounding element come in with two dots, for example ../@name for the category name. You can rename and reorder columns and edit any path directly.
Handling repeated children
A product stocked in two warehouses has two warehouse elements, and a cell can hold only one value. The converter joins such values with a semicolon by default, so the cell shows 12; 4, or it can keep only the first. When you need numbers rather than lists, use the functions count and sum in a column path: count(stock/warehouse) gives the number of warehouses and sum(stock/warehouse) the total stock. Concat combines several values with your own text in between.
Namespaces without the headache
Real-world XML such as e-invoices, shopping feeds or office documents uses namespace prefixes like cbc: or g: in front of element names. They make paths long and fragile because different files may use different prefixes for the same thing. With the ignore prefixes option on, the converter drops them, so you write product instead of p:product. Turn it off only when a file uses the same element name in two different namespaces.
Converting many files at once
Daily exports often arrive as one file per day or per order. Select them all together and the same mapping is applied to each, with the results stacked into one table and an optional column naming the source file. If you prefer, the workbook can hold one sheet per file. Each download also includes a sheet documenting the row path and column paths, which is useful when someone asks next year how the table was built.
Checking the result
Look at the row count first: it should match the number of items you expect. Then check a row with unusual content, such as an item with missing fields or several values. Empty cells mean the path found nothing for that row, which is either correct or a sign of a typo. Because the table updates as you type, you can fix a path and see the effect immediately. The XML never leaves your browser, so confidential invoices and customer feeds stay private.


%20Generator&c=%23991b1b&k=documents)
