Two XML on same payload?

Hi,

I have a payload containing two separate XMLs:

<?xml version="1.0" encoding="utf-8"?><BatteryInfo><channelId>0</channelId><chargeStatus>charging</chargeStatus><adapterStatus>solarPanel</adapterStatus><voltage>4019</voltage><current>-180</current><temperature>15</temperature><batteryPercent>100</batteryPercent><lowPower>0</lowPower><batteryVersion>2</batteryVersion></BatteryInfo>
<?xml version="1.0" encoding="utf-8"?><RfAlarmCfg version="1.1"><rfID>0</rfID><enable>1</enable><sensitivity>0</sensitivity><sensiValue>16</sensiValue><reduceFalseAlarm>0</reduceFalseAlarm><timeBlockList /><alarmHandle /></RfAlarmCfg>

How can I use the XML node to convert the 2 XMLs into 2 distinct objects?

Hi @fmarzocca,

It will help us a lot if you can provide the incoming payload you are receiving.

Put the 2 values in payload as an array, then push that through split -> XML -> join

1 Like

@marcus-j-davies the payload is exactly what I have posted.

<?xml version="1.0" encoding="utf-8"?><BatteryInfo><channelId>0</channelId><chargeStatus>chargeComplete</chargeStatus><adapterStatus>solarPanel</adapterStatus><voltage>4015</voltage><current>0</current><temperature>24</temperature><batteryPercent>100</batteryPercent><lowPower>0</lowPower><batteryVersion>2</batteryVersion></BatteryInfo>
<?xml version="1.0" encoding="utf-8"?><RfAlarmCfg version="1.1"><rfID>0</rfID><enable>1</enable><sensitivity>0</sensitivity><sensiValue>15</sensiValue><reduceFalseAlarm>0</reduceFalseAlarm><timeBlockList /><alarmHandle /></RfAlarmCfg>

So the payload is 1 string?

@Steve-Mcl the 2 XMLs are enclosed in a single string, and I cannot change it as it is coming from a device.

Then split on newline (since that full string is not valid XML as it stands)

1 Like

Yes, I got this while you were sending your answer!
Thanks.

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