XML Node only reading the first row

I’m building a workflow to process an xml file, and for this, I’m using the XML node to convert the xml data to json. Now I’m only getting the first . Any idea what I might be doing wrong?

The workflow:

And sample content of the .xml file:

<row><ItemCode>102-8803</ItemCode><ItemName>connector 3 polig</ItemName><TotalQTy>0,000000</TotalQTy><WiPQty>0,00000000000</WiPQty></row><row><ItemCode>102RXL1GE</ItemCode><ItemName>RXL 125 MARINE 1QMM YELLOW</ItemName><TotalQTy>0,000000</TotalQTy><WiPQty>0,00000000000</WiPQty></row>

Hi @dickhoning, would this be the entire file? This doesn’t seem to be valid XML as per a bunch of validators I have tested just now.

I am not very familiar with XML, but the non-unique top level node (<row>) seems be the problem here. If you simply wrap your XML String in something like <rows>...</rows> you should be able to split out each row as expected:

Example Workflow

Hope this helps!


Hi @MutedJam of course, that’s it! Thanks!

1 Like

Hey @MutedJam

I was trying to find a way to parse an XML to JSON and couldn’t figure out how to do it until i saw this post.

Can you please update the documentation somehow?

The steps i followed was.

Get an XML file (via SFTP) → Move Binary Data (Binary to JSON with Set all Data Disabled) → XML to JSON → Item Lists (Split out Items → Fields to Split Out)

Now i get a correct output table with all the data in XML that i can do what ever i like afterwads.

Thank you.

1 Like

Hey @Mulen,

What would you like us to include in the documentation? This post is more around the XML data not being valid rather than an issue with the node or documentation.

If I can understand a bit more about the issue you had I can work out what information to include in an internal ticket for the change :+1:

Hey @jon

I was searching how to convert a XML file to JSON.

I thought it was as simple as getting the file from an HTTP Node or SFT etc. and converting with XML Node

It was throwing an error at first that i have to search about it

ERROR: No json property “data” does not exists on item!

Then i searched the community and found out that you have to use the Move Binaray Data.

I did it but again throws an error

ERROR: Unexpected token < in JSON at position 0

I had to search again and see that you have to disable the Set all Data from Move Binary Data.

Then i run it again in hope that XML node will produce the correct results and show a table with the data from the XML but no!

This was what i got.

So finally i found this post here and used the Item Lists node to produce the correct results by using Split Out Items and adding at Field To Split Out field the values of the XML node that is products.product

So i got the final result i wanted

So i think you have to update somehow the documentation for people that search how to convert a XML to json and use its data to follow these steps

Thank you.

1 Like

Hey @Mulen,

That makes more sense :slight_smile:

I think for the most part part of the confusion here could be around using Binary data and the differences between binary data and JSON data internally to n8n. I think what we could do as a starting point is create a template as part of a new collection that covers how to take XML data and make it useable we can then link to it from the node documentation page.

Does that sound like something that could work for you?

1 Like

Yep that was the right words i was searching on how to describe the situation.

Yes that would be nice to have an example like this.

1 Like