can anybody share how to write json to xml file ?
Hi @Edmunds_Priede Have you taken a peek at our XML node? You can convert JSON to XML with it
XML | n8n Docs
If you have tried, can you share your workflow so we can see where you’re getting stuck?
i have managed to make xml as string but not sure how to write to it to disk.
i am tryng write binary node, but there is no binary data obviously
this is the closest i get. TBH this should be a simple operation but i am using 7 nodes.
all i need is to write json array to xml enclosed in outer element
this one looks good. from set node to write binary
{
"meta": {
"instanceId": "0f064bae8ef402bc77bc2dfa9bf8ed7b60d49005d687ffae7941232c8a9d8d44"
},
"nodes": [
{
"parameters": {
"mode": "jsonToxml",
"options": {
"cdata": false,
"headless": false,
"rootName": "products"
}
},
"id": "c2df2ba2-8298-4991-b368-4805db4c747b",
"name": "XML2",
"type": "n8n-nodes-base.xml",
"typeVersion": 1,
"position": [
760,
1220
]
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"number": [
{
"name": "price-before-discount",
"value": "={{ Number($json.price_list.brutto) + 5 }}"
},
{
"name": "ean",
"value": "={{ $json.ean }}"
},
{
"name": "price-after-discount",
"value": "={{ Number($json.price_list.brutto) + 5 }}"
},
{
"name": "=stock",
"value": "={{ $json.stock }}"
}
],
"string": [
{
"name": "sku",
"value": "={{ $json.ean }}"
}
]
},
"options": {}
},
"id": "99350739-f19f-4619-9713-b348ffa8bf64",
"name": "Set2",
"type": "n8n-nodes-base.set",
"typeVersion": 2,
"position": [
280,
1220
]
},
{
"parameters": {
"fileName": "/home/edmunds/products.xml",
"dataPropertyName": "=data",
"options": {
"append": false
}
},
"id": "d77abc0b-11b5-4ce3-9f72-80f3924346d6",
"name": "Write Binary File",
"type": "n8n-nodes-base.writeBinaryFile",
"typeVersion": 1,
"position": [
1300,
1220
]
},
{
"parameters": {
"mode": "jsonToBinary",
"convertAllData": false,
"sourceKey": "=data",
"options": {
"mimeType": "application/xml",
"useRawData": true
}
},
"id": "c0ac8cf3-a0de-43b2-9d60-8444a3ec12ca",
"name": "Move Binary Data",
"type": "n8n-nodes-base.moveBinaryData",
"typeVersion": 1,
"position": [
1020,
1220
]
},
{
"parameters": {
"operation": "aggregateItems",
"aggregate": "aggregateAllItemData",
"destinationFieldName": "product"
},
"id": "455f9ccc-011f-40b8-996f-73feb9676a60",
"name": "Item Lists2",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 2.1,
"position": [
500,
1220
]
}
],
"connections": {
"XML2": {
"main": [
[
{
"node": "Move Binary Data",
"type": "main",
"index": 0
}
]
]
},
"Set2": {
"main": [
[
{
"node": "Item Lists2",
"type": "main",
"index": 0
}
]
]
},
"Move Binary Data": {
"main": [
[
{
"node": "Write Binary File",
"type": "main",
"index": 0
}
]
]
},
"Item Lists2": {
"main": [
[
{
"node": "XML2",
"type": "main",
"index": 0
}
]
]
}
}
}```
Hey @Edmunds_Priede - thanks for sharing that Just wanted to make sure with that last workflow you’ve got this sorted?
yes , finally it works like expected. many inputs to one xml file
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.