Skip to content

Instantly share code, notes, and snippets.

@njh

njh/README.md Secret

Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njh/bce112d484f93a8c282a to your computer and use it in GitHub Desktop.
Save njh/bce112d484f93a8c282a to your computer and use it in GitHub Desktop.
Using the collector node to generate XML

This flow is an example of using the collector node type which can be found here: https://www.npmjs.org/package/node-red-contrib-collector

screenshot

After pressing the a, b and c inject buttons, the following XML is output in the debug tab:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
  <a>Value A</a>
  <b>Value B</b>
  <c>Value C</c>
</root>

Pressing the no b button causes the <b>Value B</b> element to be removed again.

[
{
"id": "9fdbd217.60243",
"type": "inject",
"name": "",
"topic": "a",
"payload": "Value A",
"payloadType": "string",
"repeat": "",
"crontab": "",
"once": false,
"x": 99.5,
"y": 150,
"z": "792ca5d.f86d35c",
"wires": [
[
"fd86696e.027998"
]
]
},
{
"id": "79ac52f6.8653ac",
"type": "inject",
"name": "",
"topic": "b",
"payload": "Value B",
"payloadType": "string",
"repeat": "",
"crontab": "",
"once": false,
"x": 99.5,
"y": 210,
"z": "792ca5d.f86d35c",
"wires": [
[
"fd86696e.027998"
]
]
},
{
"id": "fabedd69.05412",
"type": "debug",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 588,
"y": 236,
"z": "792ca5d.f86d35c",
"wires": []
},
{
"id": "d5ea0edd.2a15f",
"type": "inject",
"name": "",
"topic": "c",
"payload": "Value C",
"payloadType": "string",
"repeat": "",
"crontab": "",
"once": false,
"x": 99.5,
"y": 330,
"z": "792ca5d.f86d35c",
"wires": [
[
"fd86696e.027998"
]
]
},
{
"id": "fd86696e.027998",
"type": "collector",
"name": "",
"onlyIfChanged": false,
"x": 274.5,
"y": 236,
"z": "792ca5d.f86d35c",
"wires": [
[
"28ef5db8.d710a2"
]
]
},
{
"id": "74355c29.8bcaa4",
"type": "inject",
"name": "no b",
"topic": "b",
"payload": "",
"payloadType": "none",
"repeat": "",
"crontab": "",
"once": false,
"x": 99.5,
"y": 270,
"z": "792ca5d.f86d35c",
"wires": [
[
"fd86696e.027998"
]
]
},
{
"id": "28ef5db8.d710a2",
"type": "xml",
"name": "",
"x": 430,
"y": 236,
"z": "792ca5d.f86d35c",
"wires": [
[
"fabedd69.05412"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment