1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

add example for XML node

This commit is contained in:
Hiroyasu Nishiyama 2020-11-03 20:06:27 +09:00
parent dac7830bd4
commit ccbd179f23
3 changed files with 303 additions and 0 deletions

View File

@ -0,0 +1,92 @@
[
{
"id": "82f1bd0b.43474",
"type": "xml",
"z": "4b63452d.672afc",
"name": "",
"property": "payload",
"attr": "",
"chr": "",
"x": 530,
"y": 180,
"wires": [
[
"1cd4ad02.9a5423"
]
]
},
{
"id": "84222b92.d65d18",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 180,
"wires": [
[
"cdd1c154.3a655"
]
]
},
{
"id": "7b014430.dfd94c",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert JavaScript object to XML",
"info": "XML node can convert JavaScript object to XML string.",
"x": 240,
"y": 120,
"wires": []
},
{
"id": "1cd4ad02.9a5423",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 180,
"wires": []
},
{
"id": "cdd1c154.3a655",
"type": "template",
"z": "4b63452d.672afc",
"name": "JS object",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "plain",
"template": "{\n \"kind\": \"Apple\",\n \"price\": 100,\n \"origin\": \"Canada\"\n}",
"output": "json",
"x": 360,
"y": 180,
"wires": [
[
"82f1bd0b.43474"
]
]
}
]

View File

@ -0,0 +1,92 @@
[
{
"id": "93e423a9.a407d",
"type": "xml",
"z": "4b63452d.672afc",
"name": "",
"property": "payload",
"attr": "",
"chr": "",
"x": 530,
"y": 360,
"wires": [
[
"2d0dde7e.a50082"
]
]
},
{
"id": "ba1dab90.8d1da8",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 360,
"wires": [
[
"16617f26.14ced1"
]
]
},
{
"id": "a9f97b00.57d658",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Convert XML to JavaScript object",
"info": "XML node can convert XML string to JavaScript object.",
"x": 240,
"y": 300,
"wires": []
},
{
"id": "2d0dde7e.a50082",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 360,
"wires": []
},
{
"id": "16617f26.14ced1",
"type": "template",
"z": "4b63452d.672afc",
"name": "XML string",
"field": "payload",
"fieldType": "msg",
"format": "html",
"syntax": "plain",
"template": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<fruit id=\"100\">\n <kind>Apple</kind>\n <price>100</price>\n <origin>Canada</origin>\n</fruit>",
"output": "str",
"x": 370,
"y": 360,
"wires": [
[
"93e423a9.a407d"
]
]
}
]

View File

@ -0,0 +1,119 @@
[
{
"id": "581bd648.636628",
"type": "xml",
"z": "4b63452d.672afc",
"name": "",
"property": "payload",
"attr": "",
"chr": "",
"x": 710,
"y": 540,
"wires": [
[
"b74237dc.1e5028"
]
]
},
{
"id": "d0899f9b.f1ac6",
"type": "inject",
"z": "4b63452d.672afc",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 540,
"wires": [
[
"f04ffb9a.68edb8"
]
]
},
{
"id": "8a214c05.dc61f",
"type": "comment",
"z": "4b63452d.672afc",
"name": "Control conversion using options property",
"info": "XML node can control conversion by setting `options` property (defined by [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/README.md#options)) in input message.",
"x": 260,
"y": 480,
"wires": []
},
{
"id": "b74237dc.1e5028",
"type": "debug",
"z": "4b63452d.672afc",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 540,
"wires": []
},
{
"id": "f04ffb9a.68edb8",
"type": "template",
"z": "4b63452d.672afc",
"name": "XML string",
"field": "payload",
"fieldType": "msg",
"format": "html",
"syntax": "plain",
"template": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<fruit id=\"100\">\n <kind>Apple</kind>\n <price>100</price>\n <origin>Canada</origin>\n</fruit>",
"output": "str",
"x": 370,
"y": 540,
"wires": [
[
"fedf79.5889c088"
]
]
},
{
"id": "fedf79.5889c088",
"type": "change",
"z": "4b63452d.672afc",
"name": "set options",
"rules": [
{
"t": "set",
"p": "options",
"pt": "msg",
"to": "{\"explicitArray\":false}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 540,
"wires": [
[
"581bd648.636628"
]
]
}
]