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"]]}]

Flow Info

Created 10 years, 3 months ago
Updated 9 years, 4 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • inject (x4)
  • xml (x1)
Other
  • collector (x1)

Tags

  • collector
  • state
  • xml
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option