How convert XML to XSLX

Describe the issue/error/question

Hello, I want to convert an XML file received by an email to XLSX. But I dont know how. Thinking a little I figure out I can convert XML to JSON and then convert JSON to XML but the XLSX has everysingle XML tag as a row.

Please share the workflow

Share the output returned by the last node

The xlsx with this method look like this
image

But these have to look like this

Information on your n8n setup

  • **n8n version:**0.203.0
  • Database you’re using (default: SQLite): MongoDB
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker

Hi @aartaza

Welcome to the community.
Xml like Json is a structured dataset that has nested values aswell. So creating a flat xlsx table with that is not as easy as simply converting it.
What does your xml look like, can you give an example?

2 Likes

Yes of course, Im going to send a test XML example.

<Workbook
	xmlns="urn:schemas-microsoft-com:office:spreadsheet"
	xmlns:o="urn:schemas-microsoft-com:office:office"
	xmlns:x="urn:schemas-microsoft-com:office:excel"
	xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
	xmlns:html="http://www.w3.org/TR/REC-html40">
	<DocumentProperties
		xmlns="urn:schemas-microsoft-com:office:office">
		<Author>Usuario</Author>
		<LastAuthor>Usuario</LastAuthor>
		<Created>2022-07-15T11:03:09Z</Created>
		<LastSaved>2022-07-15T11:03:09Z</LastSaved>
		<Version>12.00</Version>
	</DocumentProperties>
	<ExcelWorkbook
		xmlns="urn:schemas-microsoft-com:office:excel">
		<WindowHeight>8130</WindowHeight>
		<WindowWidth>15135</WindowWidth>
		<WindowTopX>120</WindowTopX>
		<WindowTopY>45</WindowTopY>
		<ProtectStructure>False</ProtectStructure>
		<ProtectWindows>False</ProtectWindows>
	</ExcelWorkbook>
	<Styles>
		<Style ss:ID="Default" ss:Name="Normal">
			<Alignment ss:Vertical="Center"/>
			<Borders/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="9" ss:Color="#000000"/>
			<Interior/>
			<NumberFormat/>
			<Protection/>
		</Style>
		<Style ss:ID="h00001">
			<Alignment ss:Horizontal="Left" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="8" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#F0F0F0" ss:Pattern="Solid"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
			</Borders>
		</Style>
		<Style ss:ID="h00002">
			<Alignment ss:Horizontal="Left" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="9" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#F0F0F0" ss:Pattern="Solid"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
			</Borders>
		</Style>
		<Style ss:ID="h00003">
			<Alignment ss:Horizontal="Right" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="9" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#F0F0F0" ss:Pattern="Solid"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
			</Borders>
		</Style>
		<Style ss:ID="h00004">
			<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="9" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#F0F0F0" ss:Pattern="Solid"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#646464"/>
			</Borders>
		</Style>
		<Style ss:ID="c00001">
			<Alignment ss:Horizontal="Right" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="7" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#FFFFFF" ss:Pattern="Solid"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
			</Borders>
		</Style>
		<Style ss:ID="c00002">
			<Alignment ss:Horizontal="Left" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="8" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#FFFFFF" ss:Pattern="Solid"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
			</Borders>
		</Style>
		<Style ss:ID="c00003">
			<Alignment ss:Horizontal="Right" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="8" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#FFFFFF" ss:Pattern="Solid"/>
			<NumberFormat ss:Format="#,##0.000"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
			</Borders>
		</Style>
		<Style ss:ID="c00004">
			<Alignment ss:Horizontal="Right" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="7" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#FFFFFF" ss:Pattern="Solid"/>
			<NumberFormat ss:Format="#,##0.0"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
			</Borders>
		</Style>
		<Style ss:ID="c00005">
			<Alignment ss:Horizontal="Right" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="7" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#FFFFFF" ss:Pattern="Solid"/>
			<NumberFormat ss:Format="#,##0.00"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
			</Borders>
		</Style>
		<Style ss:ID="c00006">
			<Alignment ss:Horizontal="Right" ss:Vertical="Center"/>
			<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="8" ss:Color="#000000"
    ss:Bold="0" ss:Italic="0" ss:StrikeThrough="0"/>
			<Interior ss:Color="#C8D2D7" ss:Pattern="Solid"/>
			<NumberFormat ss:Format="#,##0.000"/>
			<Borders>
				<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
				<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#808080"/>
			</Borders>
		</Style>
	</Styles>
	<Worksheet ss:Name="Tucana">
		<Table ss:ExpandedColumnCount="10" ss:ExpandedRowCount="41" x:FullColumns="1"
   x:FullRows="1" ss:DefaultRowHeight="18">
			<Column ss:AutoFitWidth="0" ss:Width="25"/>
			<Column ss:AutoFitWidth="0" ss:Width="115"/>
			<Column ss:AutoFitWidth="0" ss:Width="90"/>
			<Column ss:AutoFitWidth="0" ss:Width="700"/>
			<Column ss:AutoFitWidth="0" ss:Width="65"/>
			<Column ss:AutoFitWidth="0" ss:Width="84"/>
			<Column ss:AutoFitWidth="0" ss:Width="25"/>
			<Column ss:AutoFitWidth="0" ss:Width="35"/>
			<Column ss:AutoFitWidth="0" ss:Width="35"/>
			<Column ss:AutoFitWidth="0" ss:Width="84"/>
			<Row ss:AutoFitHeight="0" ss:Height="22">
				<Cell ss:StyleID="h00002">
					<Data ss:Type="String">Lin.</Data>
				</Cell>
				<Cell ss:StyleID="h00002">
					<Data ss:Type="String"> Art�culo</Data>
				</Cell>
				<Cell ss:StyleID="h00002">
					<Data ss:Type="String"> Matr�cula</Data>
				</Cell>
				<Cell ss:StyleID="h00002">
					<Data ss:Type="String"> Descripci�n</Data>
				</Cell>
				<Cell ss:StyleID="h00003">
					<Data ss:Type="String">Cantidad </Data>
				</Cell>
				<Cell ss:StyleID="h00003">
					<Data ss:Type="String">Precio C. </Data>
				</Cell>
				<Cell ss:StyleID="h00004">
					<Data ss:Type="String">IVA</Data>
				</Cell>
				<Cell ss:StyleID="h00003">
					<Data ss:Type="String">Dto. </Data>
				</Cell>
				<Cell ss:StyleID="h00002">
					<Data ss:Type="String"> Dto.2</Data>
				</Cell>
				<Cell ss:StyleID="h00003">
					<Data ss:Type="String">Total </Data>
				</Cell>
			</Row>
			<Row ss:AutoFitHeight="0">
				<Cell ss:StyleID="c00001">
					<Data ss:Type="Number">1.00</Data>
				</Cell>
				<Cell ss:StyleID="c00002">
					<Data ss:Type="String"></Data>
				</Cell>
				<Cell ss:StyleID="c00002">
					<Data ss:Type="String"></Data>
				</Cell>
				<Cell ss:StyleID="c00002">
					<Data ss:Type="String">FRA. N� SD.52513</Data>
				</Cell>
				<Cell ss:StyleID="c00003">
					<Data ss:Type="Number">0.000</Data>
				</Cell>
				<Cell ss:StyleID="c00003">
					<Data ss:Type="Number">0.000000</Data>
				</Cell>
				<Cell ss:StyleID="c00004">
					<Data ss:Type="Number">21.0</Data>
				</Cell>
				<Cell ss:StyleID="c00005">
					<Data ss:Type="Number">0.00</Data>
				</Cell>
				<Cell ss:StyleID="c00005">
					<Data ss:Type="Number">0.00</Data>
				</Cell>
				<Cell ss:StyleID="c00006">
					<Data ss:Type="Number">0.000000</Data>
				</Cell>
			</Row>
		</Table>
		<WorksheetOptions
			xmlns="urn:schemas-microsoft-com:office:excel">
			<PageSetup>
				<Header x:Margin="0.31496062000000002"/>
				<Footer x:Margin="0.31496062000000002"/>
				<PageMargins x:Bottom="0.78740157499999996" x:Left="0.511811024"
     x:Right="0.511811024" x:Top="0.78740157499999996"/>
			</PageSetup>
			<Unsynced/>
			<Print>
				<ValidPrinterInfo/>
				<PaperSizeIndex>9</PaperSizeIndex>
				<HorizontalResolution>300</HorizontalResolution>
				<VerticalResolution>300</VerticalResolution>
			</Print>
			<Selected/>
			<FreezePanes/>
			<FrozenNoSplit/>
			<SplitHorizontal>1</SplitHorizontal>
			<TopRowBottomPane>1</TopRowBottomPane>
			<ActivePane>2</ActivePane>
			<Panes>
				<Pane>
					<Number>3</Number>
				</Pane>
				<Pane>
					<Number>2</Number>
				</Pane>
			</Panes>
			<ProtectObjects>False</ProtectObjects>
			<ProtectScenarios>False</ProtectScenarios>
		</WorksheetOptions>
		<AutoFilter x:Range="R1C1:R41C10"
			xmlns="urn:schemas-microsoft-com:office:excel">
		</AutoFilter>
	</Worksheet>
</Workbook> 

aha, yes this is not just an xml its actually the xml of an xlsx file.
not sure what your usecase is.

Ohhh, I see. Maybe using excel API or something like that

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.