# Join payload and split

**URL:** <https://discourse.nodered.org/t/join-payload-and-split/36199>\
**Category:** General\
**Created:** [19 November 2020 15:13 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199 "2020-11-19T15:13:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [19 November 2020 15:13 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/1 "2020-11-19T15:13:24Z")

</div>

Hi.  
I have a sliced xml that arrives in serveral payloads in string format. I want to listen on the payloads and have an output that starts with and ends with from a payload to a payload that arrives later so i can convert it back to xml with a valid start and end tag.

Hard to explain.  
i attach a picture of the payloads so maybe you understand what i mean.

/niclas

 ![payload](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a463b6be0e5f1a6984c772b40af81ba2811b788.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 November 2020 16:18 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/2 "2020-11-19T16:18:48Z")

</div>

here is an example of a split xml joined as a string.  
the 3 injects hold the 3 xml parts only when last one is sent does the xml get passed on. Only if parts are in order does this work

```auto
[{"id":"a8c11fb9.9055","type":"inject","z":"8d22ae29.7df6d","name":"part 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CATALOG><CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Columbia</COMPANY><PRICE>10.90</PRICE><YEAR>1985</YEAR></CD><CD><TITLE>Hide your heart</TITLE><ARTIST>Bonnie Tyler</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS Records</COMPANY><PRICE>9.90</PRICE><YEAR>1988</YEAR></CD>","payloadType":"str","x":200,"y":1720,"wires":[["76e122df.8ed87c"]]},{"id":"76e122df.8ed87c","type":"function","z":"8d22ae29.7df6d","name":"","func":"if (msg.payload.substr(-10) === \"</CATALOG>\"){\n msg.complete = true\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":1800,"wires":[["d97c11aa.2c90b8"]]},{"id":"d97c11aa.2c90b8","type":"join","z":"8d22ae29.7df6d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":590,"y":1800,"wires":[["2da22367.b6999c"]]},{"id":"c815e9db.a393f8","type":"inject","z":"8d22ae29.7df6d","name":"part 2","props":[{"p":"payload"},{"p":"topic","v":"$moment().tz(\"Euroupe/London\")","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CD><TITLE>Still got the blues</TITLE><ARTIST>Gary Moore</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Virgin records</COMPANY><PRICE>10.20</PRICE><YEAR>1990</YEAR></CD><CD><TITLE>Eros</TITLE><ARTIST>Eros Ramazzotti</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>BMG</COMPANY><PRICE>9.90</PRICE><YEAR>1997</YEAR></CD>","payloadType":"str","x":170,"y":1800,"wires":[["76e122df.8ed87c"]]},{"id":"49f73435.47a794","type":"inject","z":"8d22ae29.7df6d","name":"part 3","props":[{"p":"payload"},{"p":"topic","v":"$toMillis($now())","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CD><TITLE>One night only</TITLE><ARTIST>Bee Gees</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Polydor</COMPANY><PRICE>10.90</PRICE><YEAR>1998</YEAR></CD><CD><TITLE>Sylvias Mother</TITLE><ARTIST>Dr.Hook</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS</COMPANY><PRICE>8.10</PRICE><YEAR>1973</YEAR></CD></CATALOG>","payloadType":"str","x":190,"y":1880,"wires":[["76e122df.8ed87c"]]},{"id":"2da22367.b6999c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":1800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [19 November 2020 21:33 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/3 "2020-11-19T21:33:55Z")

</div>

Hi.

I your example the first xml is starting with   
But in my case the xml can start with anywhere. so it must start to search for and then set msg.complete when it finds   
Can I somehow even declare the start tag also?

/regards Niclas

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 November 2020 21:39 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/4 "2020-11-19T21:39:57Z")

</div>

Without understanding exactly how yor xml is sent its difficult to say,.  
Can you give a slimmed down representation of the recived payloads?

Maybe something like this will work.

```auto
[{"id":"a8c11fb9.9055","type":"inject","z":"8d22ae29.7df6d","name":"part 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CD><TITLE>One night only</TITLE><ARTIST>Bee Gees</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Polydor</COMPANY><PRICE>10.90</PRICE><YEAR>1998</YEAR></CD><CD><TITLE>Sylvias Mother</TITLE><ARTIST>Dr.Hook</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS</COMPANY><PRICE>8.10</PRICE><YEAR>1973</YEAR></CD></CATALOG><CATALOG><CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Columbia</COMPANY><PRICE>10.90</PRICE><YEAR>1985</YEAR></CD><CD><TITLE>Hide your heart</TITLE><ARTIST>Bonnie Tyler</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS Records</COMPANY><PRICE>9.90</PRICE><YEAR>1988</YEAR></CD>","payloadType":"str","x":200,"y":1720,"wires":[["76e122df.8ed87c"]]},{"id":"76e122df.8ed87c","type":"function","z":"8d22ae29.7df6d","name":"","func":"let tag = \"CATALOG\"\nlet splitStart = msg.payload.split(\"<\"+tag+\">\");\nif (splitStart.length > 1) {\n msg.payload = (context.get(\"splitStart\") || \"\")+splitStart[0];\n context.set(\"splitStart\", \"<\"+tag+\">\"+splitStart[1]);\n msg.complete = true\n}else{\n msg.payload = (context.get(\"splitStart\") || \"\")+msg.payload;\n context.set(\"splitStart\", \"\");\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":1800,"wires":[["d97c11aa.2c90b8"]]},{"id":"c815e9db.a393f8","type":"inject","z":"8d22ae29.7df6d","name":"part 2","props":[{"p":"payload"},{"p":"topic","v":"$moment().tz(\"Euroupe/London\")","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CD><TITLE>Still got the blues</TITLE><ARTIST>Gary Moore</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Virgin records</COMPANY><PRICE>10.20</PRICE><YEAR>1990</YEAR></CD><CD><TITLE>Eros</TITLE><ARTIST>Eros Ramazzotti</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>BMG</COMPANY><PRICE>9.90</PRICE><YEAR>1997</YEAR></CD>","payloadType":"str","x":170,"y":1800,"wires":[["76e122df.8ed87c"]]},{"id":"d97c11aa.2c90b8","type":"join","z":"8d22ae29.7df6d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":1800,"wires":[["2da22367.b6999c"]]},{"id":"2da22367.b6999c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"$substring(payload, 0, 11) & $substring(payload,-11)","statusType":"jsonata","x":710,"y":1800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [24 November 2020 12:06 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/5 "2020-11-24T12:06:46Z")

</div>

Hi .

I have tried a lot with your function node. But i don´t really understand all of the code in it.  
I will attach a nobe example that i did that almost works. But sometimes it don´t work and i really don´t know why?

The picture i attach from the debug is using my example code. Maybe it´s easier to understand what i trying to accomplish.

Best regards Niiclas

 ![3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/445c7090f04373539a64627e6b0b20b1b2ae3345.jpeg) ![4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/ebdd19f0c2113ac6b6d15537561c469816f0117b.jpeg)

```auto
[{"id":"9a851d64.7e405","type":"function","z":"85cbf67a.52f0a8","name":"utf8","func":"msg.payload = msg.payload.toString('utf8');\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":380,"wires":[["4c1e2f23.08b8c","61cba11f.399a8"]]},{"id":"4c1e2f23.08b8c","type":"split","z":"85cbf67a.52f0a8","name":"","splt":"<event id=","spltType":"str","arraySplt":"2","arraySpltType":"len","stream":false,"addname":"","x":190,"y":420,"wires":[["b535b318.12c06"]]},{"id":"b535b318.12c06","type":"function","z":"85cbf67a.52f0a8","name":"","func":"msg.payload = \"<event id=\"+msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":420,"wires":[["1367e5d5.84a2ca"]]},{"id":"1367e5d5.84a2ca","type":"function","z":"85cbf67a.52f0a8","name":"","func":"if (msg.payload === \"</event>\"){\n msg.complete = true\n}\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":420,"wires":[["f7973ca3.92db5"]]},{"id":"f7973ca3.92db5","type":"xml","z":"85cbf67a.52f0a8","name":"","property":"payload","attr":"","chr":"","x":630,"y":440,"wires":[["e980bc1a.f6ad9"]]}]

```

/regards Niclas

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [24 November 2020 13:26 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/6 "2020-11-24T13:26:16Z")

</div>

I still need a copy of the full incoming xml (i can not copy and paste from images it looks like you just want a section of a larger xml. Your code will not work as you need to store the parts until the final tag is recieved.  
try this but if i does not work i will need to see a xml that i can copy and past, i have added some comments to function so you get some idea of what code is doing.

```auto
[{"id":"a8c11fb9.9055","type":"inject","z":"8d22ae29.7df6d","name":"part 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CD><TITLE>One night only</TITLE><ARTIST>Bee Gees</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Polydor</COMPANY><PRICE>10.90</PRICE><YEAR>1998</YEAR></CD><CD><TITLE>Sylvias Mother</TITLE><ARTIST>Dr.Hook</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS</COMPANY><PRICE>8.10</PRICE><YEAR>1973</YEAR></CD></event></batch><batch><event id=123456><CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Columbia</COMPANY><PRICE>10.90</PRICE><YEAR>1985</YEAR></CD><CD><TITLE>Hide your heart</TITLE><ARTIST>Bonnie Tyler</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS Records</COMPANY><PRICE>9.90</PRICE><YEAR>1988</YEAR></CD>","payloadType":"str","x":200,"y":1720,"wires":[["76e122df.8ed87c"]]},{"id":"c815e9db.a393f8","type":"inject","z":"8d22ae29.7df6d","name":"part 2","props":[{"p":"payload"},{"p":"topic","v":"$moment().tz(\"Euroupe/London\")","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<CD><TITLE>Still got the blues</TITLE><ARTIST>Gary Moore</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Virgin records</COMPANY><PRICE>10.20</PRICE><YEAR>1990</YEAR></CD><CD><TITLE>Eros</TITLE><ARTIST>Eros Ramazzotti</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>BMG</COMPANY><PRICE>9.90</PRICE><YEAR>1997</YEAR></CD>","payloadType":"str","x":170,"y":1800,"wires":[["76e122df.8ed87c"]]},{"id":"76e122df.8ed87c","type":"function","z":"8d22ae29.7df6d","name":"","func":"let tag = \"event\" //the tag\nlet splitStart = msg.payload.split(\"<\"+tag);\nif (splitStart.length > 1) {\n msg.payload = (context.get(\"splitStart\") || \"\")+splitStart[0].split(\"</batch>\")[0];//add final section to stored start and split of batch\n context.set(\"splitStart\", \"<\"+tag+splitStart[1]);//store start of new tag\n msg.complete = true //send complete msg\n}else{\n msg.payload = (context.get(\"splitStart\") || \"\")+msg.payload; // add to stored xml start\n context.set(\"splitStart\", \"\");//store unfinished xml\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":1800,"wires":[["d97c11aa.2c90b8"]]},{"id":"d97c11aa.2c90b8","type":"join","z":"8d22ae29.7df6d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":1800,"wires":[["2da22367.b6999c"]]},{"id":"2da22367.b6999c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"$substring(payload, 0, 11) & $substring(payload,-11)","statusType":"jsonata","x":710,"y":1800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [24 November 2020 20:38 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/7 "2020-11-24T20:38:35Z")

</div>

Hi. Have tried your last code and edited the tags. The start tag seem to work fine but can't make it work with the end tag.

I the example below i have put the first parts of the xml in inject nodes like you did in your example.

Thanks for your help so far  
Best regards Niclas

```auto
[{"id":"31516a09.6e38e6","type":"inject","z":"6796c4f2.adaf9c","name":"part 1","topic":"","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <events> <batch name=\"acs.installationtree.update\"> <event id=\"501738\" name=\"acs.door.forcedOpenOff\" type=\"user\" timestamp=\"1606201683114\" operator=\"5\" operatorName=\"master\"> <argument value=\"Entré\" type=\"dac\" id=\"13\" externalId=\"ID:13_20160324_141514\"/> <argument value=\"DacProperties[address=0, name='Entré', active='true', controllerId='7']\" type=\"dac_properties\" id=\"\"> <![CDATA[<dac> <name>Entré</name> <address>0</address> <active>true</active> <controllerId>7</controllerId> <externalId>ID:13_20160324_141514</externalId> <delayUnlockTime>0</delayUnlockTime> <unlockPulseTime>6000</unlockPulseTime> <alarmShuntHoldTime>500</alarmShuntHoldTime> <permittedDoorOpenTime>30000</permittedDoorOpenTime> <warningBeforeArmTime>30000</warningBeforeArmTime> <delayTimeBeforeRelock>2000</delayTimeBeforeRelock> <doorMonitorInputsChained>false</doorMonitorInputsChained> <doorMonitorInputSupervised>false</doorMonitorInputSupervised> <unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess> <retai","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":2360,"wires":[["e26f1fd8.32899"]]},{"id":"45af0b2d.bf86b4","type":"inject","z":"6796c4f2.adaf9c","name":"part 2","topic":"","payload":"nModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>true</hio></dac>]]></argument><argument value=\"DacProperties[address=0, name='Entré', active='false', controllerId='7']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Entré</name><address>0</address><active>false</active><controllerId>7</controllerId><externalId>ID:13_20160324_141514</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>500</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>2000</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>true</hio></dac>]]></argument></event><event id=\"501737\" name=\"acs.door.forcedBlockOff\" type=\"user\" timestamp=\"1606201683114\" operator=\"5\" operatorName=\"master\"><argument value=\"Entré\" type=\"dac\" id=\"13\" externalId=\"ID:13_20160324_141514\"/><argument value=\"DacProperties[address=0, name='Entré', active='true', controllerId='7']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Entré</name><address>0</address><active>true</active><controllerId>7</controllerId><externalId>ID:13_20160324_141514</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>500</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>2000</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>true</hio></dac>]]></argument><argument value=\"DacProperties[address=0, name='Entré', active='false', controllerId='7']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Entré</name><address>0</address><active>false</active><controllerId>7</controllerId><externalId>ID:13_20160324_141514</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>500</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>2000</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>true</hio></dac>]]></argument></event></batch><batch name=\"commserver.forceOpen\"><event id=\"487245\" name=\"acs.door.forcedOpenOff\" type=\"user\" timestamp=\"1605790225016\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>true</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument></event><event id=\"487244\" name=\"acs.door.forcedBlockOff\" type=\"user\" timestamp=\"1605790225016\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>true</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument></event></batch><batch name=\"commserver.forceOpen\"><event id=\"487231\" name=\"acs.door.forcedOpenOn\" type=\"user\" timestamp=\"1605790218343\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>false</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtCommunicationFailure>true</retainModeAtCommunicationFailure><unlockAtDualSwipe>false</unlockAtDualSwipe><dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReader","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":2440,"wires":[["e26f1fd8.32899"]]},{"id":"fe99b714.d13ef8","type":"inject","z":"6796c4f2.adaf9c","name":"part 3","topic":"","payload":"Blocked>false</entryReaderBlocked><exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>true</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument></event><event id=\"487230\" name=\"acs.door.forcedBlockOff\" type=\"user\" timestamp=\"1605790218343\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/><argument value=\"DacProperties[address=2, name='Lindaaaaahl', active='true', controllerId='11']\" type=\"dac_properties\" id=\"\"><![CDATA[<dac><name>Lindaaaaahl</name><address>2</address><active>true</active><controllerId>11</controllerId><externalId>ID:26_20181220_130306</externalId><delayUnlockTime>0</delayUnlockTime><unlockPulseTime>6000</unlockPulseTime><alarmShuntHoldTime>2000</alarmShuntHoldTime><permittedDoorOpenTime>30000</permittedDoorOpenTime><warningBeforeArmTime>30000</warningBeforeArmTime><delayTimeBeforeRelock>500</delayTimeBeforeRelock><doorMonitorInputsChained>false</doorMonitorInputsChained><doorMonitorInputSupervised>false</doorMonitorInputSupervised><unlockMotorLockAtFirstAccess>true</unlockMotorLockAtFirstAccess><retainModeAtComm","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":2520,"wires":[["e26f1fd8.32899"]]},{"id":"e26f1fd8.32899","type":"function","z":"6796c4f2.adaf9c","name":"","func":"let tag = \"event id\" //the tag\nlet splitStart = msg.payload.split(\"<\"+tag);\nif (splitStart.length > 1) {\n msg.payload = (context.get(\"splitStart\") || \"\")+splitStart[0].split(\"</event>\")[0];//add final section to stored start and split of batch\n context.set(\"splitStart\", \"<\"+tag+splitStart[1]);//store start of new tag\n msg.complete = true //send complete msg\n}else{\n msg.payload = (context.get(\"splitStart\") || \"\")+msg.payload; // add to stored xml start\n context.set(\"splitStart\", \"\");//store unfinished xml\n}\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":2460,"wires":[["a55367b5.0fb7b8"]]},{"id":"a55367b5.0fb7b8","type":"debug","z":"6796c4f2.adaf9c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":480,"y":2400,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [24 November 2020 22:19 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/8 "2020-11-24T22:19:54Z")

</div>

Ok with your data it is a bit different  
i shorten data but should work with longer form

```auto
[{"id":"5af14f5a.cd6fe","type":"inject","z":"8d22ae29.7df6d","name":"part 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <events> <batch name=\"acs.installationtree.update\"> <event id=\"501738\" name=\"acs.door.forcedOpenOff\" type=\"user\" timestamp=\"1606201683114\" operator=\"5\" operatorName=\"master\"> ","payloadType":"str","x":150,"y":1720,"wires":[["74ec2a60.d48064"]]},{"id":"74ec2a60.d48064","type":"function","z":"8d22ae29.7df6d","name":"","func":"let tag = \"event id\" //the tag\nlet splitStart = msg.payload.split(\"<\"+tag);\nif (splitStart.length > 1) {\n if (context.get(\"splitStart\") !== 1){\n msg.payload = \"<\"+tag+splitStart[1];\n context.set(\"splitStart\", 1);\n }else{\n msg.payload = splitStart[0];\n msg.complete = true //send complete msg\n context.set(\"splitStart\", 0);\n }\n}else{\n if (context.get(\"splitStart\") !== 1 ){\n msg.payload =\"\";\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":1780,"wires":[["3defb2d9.64f5ce"]]},{"id":"3c759e03.8b7e12","type":"inject","z":"8d22ae29.7df6d","name":"part 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"nModeAtCommunicationFailure>true</retainMo<dacMode>STANDARD</dacMode><unlockMode>false</unlockMode><buttonEnable>false</buttonEnable><buzzerEnable>false</buzzerEnable><entryReaderBlocked>false</entryReaderBlocked>","payloadType":"str","x":150,"y":1760,"wires":[["74ec2a60.d48064"]]},{"id":"ac7713c3.54d16","type":"inject","z":"8d22ae29.7df6d","name":"part 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<exitReaderBlocked>false</exitReaderBlocked><entryReaderDoorCode>false</entryReaderDoorCode><exitReaderDoorCode>false</exitReaderDoorCode><entryReaderSystemCard>false</entryReaderSystemCard><exitReaderSystemCard>false</exitReaderSystemCard><retainRelayStatus>false</retainRelayStatus><forceOpen>true</forceOpen><forceClose>false</forceClose><hio>false</hio></dac>]]></argument></event><event id=\"487230\" name=\"acs.door.forcedBlockOff\" type=\"user\" timestamp=\"1605790218343\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/>","payloadType":"str","x":150,"y":1800,"wires":[["74ec2a60.d48064"]]},{"id":"3defb2d9.64f5ce","type":"join","z":"8d22ae29.7df6d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":1800,"wires":[["2da22367.b6999c"]]},{"id":"2da22367.b6999c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"$substring(payload, 0, 11) & $substring(payload,-11)","statusType":"jsonata","x":710,"y":1800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [25 November 2020 20:47 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/9 "2020-11-25T20:47:05Z")

</div>

Hi again.

with my example code it works great. But the xml is different every time so when I tested it on the http stream It did not work. Somehow it must look at the end tag also. I have much to learn about coding but If I understad this right msg.payload = "\<"+tag+splitStart[1]; is \<event id to \<event id. Is It possible to change this to something like this?

let tag = "event id" //the tag  
let splitStart = msg.payload.split("\<"+tag);  
if (splitStart.length \> 1) {  
if (context.get("splitStart") !== 1){  
**msg.payload = "\<"+event/\>+splitStart[1];**  
context.set("splitStart", 1);  
}else{  
msg.payload = splitStart[0];  
msg.complete = true //send complete msg  
context.set("splitStart", 0);  
}  
}else{  
if (context.get("splitStart") !== 1 ){  
msg.payload ="";  
}  
}  
return msg;

I need it to look for start \<event id=. and stop tag

and then start over to look for \<event id= again

everything between and when its find \<event id= again is garbage.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [25 November 2020 21:38 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/10 "2020-11-25T21:38:45Z")

</div>

I don't think it matters as in your example `<event id ="33344" etc>` is preceded by `</event>` so it doesn't matter which you split on, either will do but you need to replace the split search text.

I need to see the structure of your xml, preferably with out the junk, just the tags. As at moment i am only guessing.

Try this it will spit junk first message the settle to read tag. The injects contain a example of non split tags and a event tag, Every time it sees event tags it will complete the message join, and save the new start tag.

```auto
[{"id":"3c759e03.8b7e12","type":"inject","z":"8d22ae29.7df6d","name":"<###><###>","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"#########222Front#######nM<dacMode>STANDARD</dacMode>#####222End#####","payloadType":"str","x":180,"y":1760,"wires":[["74ec2a60.d48064"]]},{"id":"74ec2a60.d48064","type":"function","z":"8d22ae29.7df6d","name":"","func":"let tag = \"event id\"; //the tag\nlet splitStart = msg.payload.split(\"<\"+tag);\nif (splitStart.length > 1) {\n msg.payload = context.get(\"splithold\")+splitStart[0];\n context.set(\"splithold\", \"<\"+tag+splitStart[1]);\n msg.complete = true //send complete msg\n\n}else{\n msg.payload = context.get(\"splithold\")+msg.payload;\n context.set(\"splithold\", \"\")\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":1740,"wires":[["3defb2d9.64f5ce"]]},{"id":"ac7713c3.54d16","type":"inject","z":"8d22ae29.7df6d","name":"<##></event><event id><##>","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"######333Front#####<forceClose>false</forceClose><hio>false</hio></dac>]]></argument></event><event id=\"487230\" name=\"acs.door.forcedBlockOff\" type=\"user\" timestamp=\"1605790218343\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/######333End#####","payloadType":"str","x":250,"y":1800,"wires":[["74ec2a60.d48064"]]},{"id":"3defb2d9.64f5ce","type":"join","z":"8d22ae29.7df6d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":1740,"wires":[["2da22367.b6999c"]]},{"id":"2da22367.b6999c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"$substring(payload, 0, 11) & $substring(payload,-11)","statusType":"jsonata","x":710,"y":1800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [25 November 2020 22:27 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/11 "2020-11-25T22:27:21Z")

</div>

Hi again. this looked better but still some errors with unclosed end tags. I will give you more examples of the xml tomorrow.

I really appreciate your help with this!!!

Best regards Niclas

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [25 November 2020 22:44 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/12 "2020-11-25T22:44:12Z")

</div>

may be some junk between the event tags  
Try this asit filters out the anything between `</event> filteres here<event id="2345" etc>`

```auto
[{"id":"3c759e03.8b7e12","type":"inject","z":"8d22ae29.7df6d","name":"<###><###>","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"#########222Front#######nM<dacMode>STANDARD</dacMode>#####222End#####","payloadType":"str","x":180,"y":1760,"wires":[["74ec2a60.d48064"]]},{"id":"74ec2a60.d48064","type":"function","z":"8d22ae29.7df6d","name":"","func":"let tagE = \"</event>\", //the tag\ntagS =\"<event id\",\nsplitStart = msg.payload.split(tagE);\nif (splitStart.length > 1) {\n msg.payload = context.get(\"splithold\")+splitStart[0]+tagE;\n context.set(\"splithold\", tagS+(splitStart[1].split(tagS)[1]));\n msg.complete = true //send complete msg\n\n}else{\n msg.payload = context.get(\"splithold\")+msg.payload;\n context.set(\"splithold\", \"\")\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":1740,"wires":[["3defb2d9.64f5ce"]]},{"id":"ac7713c3.54d16","type":"inject","z":"8d22ae29.7df6d","name":"<##></event><event id><##>","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"######333Front#####<forceClose>false</forceClose><hio>false</hio></dac>]]></argument></event>some junk<event id=\"487230\" name=\"acs.door.forcedBlockOff\" type=\"user\" timestamp=\"1605790218343\" operator=\"5\" operatorName=\"master\"><argument value=\"Lindaaaaahl\" type=\"dac\" id=\"26\" externalId=\"ID:26_20181220_130306\"/######333End#####","payloadType":"str","x":250,"y":1800,"wires":[["74ec2a60.d48064"]]},{"id":"3defb2d9.64f5ce","type":"join","z":"8d22ae29.7df6d","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":1740,"wires":[["2da22367.b6999c"]]},{"id":"2da22367.b6999c","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"$substring(payload, 0, 11) & $substring(payload,-11)","statusType":"jsonata","x":710,"y":1800,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 January 2021 22:44 UTC](https://discourse.nodered.org/t/join-payload-and-split/36199/13 "2021-01-24T22:44:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
