web stats
Insert XML values - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-02-2019, 05:42 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default Insert XML values

<Message>
<City>
<City.Name>New York</City.Name>
</City>
<house>
<Kitchen>
<Kitchen.Sink>1</Kitchen.Sink>
</Kitchen>
<Bed>
<Bed.Lamp>1</Bed.Lamp>
</Bed>
</house>
</Message>



The message gets batched at the <City> level. I need to copy
<City>
<City.Name>New York</City.Name>
</City>

into the rest of the XML body, and place it right after </Bed>. The value of the city will be dynamic, as it differes on each message.

I've tried making a outbound template such as below but does not seem to work:

tmp['City']['City.Name'] = msg['City']['City.Name'].toString();

Also tried mapping values from <city></city> but it seems to copy the literal value of the map.

Any ideas would be appreciated.

Last edited by gojoshi; 10-02-2019 at 05:47 AM.
Reply With Quote
  #2  
Old 10-02-2019, 01:23 PM
agermano agermano is online now
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,099
agermano is on a distinguished road
Default

Not sure if this will always work depending on what your real messages look like, but for this example, you can do:

Code:
msg.house.Bed += msg.City
Reply With Quote
  #3  
Old 10-03-2019, 06:09 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 50
gojoshi is on a distinguished road
Default

Thank You agermano, that does work.
Reply With Quote
  #4  
Old 10-03-2019, 08:06 AM
agermano agermano is online now
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,099
agermano is on a distinguished road
Default

If you have no Bed child nodes of house this will append City as the last child node of house.

If you have more than one Bed child node of house this could potentially reorder child nodes of house (all Bed nodes will be grouped together, a copy of msg.City will be appended, any nodes between your Bed nodes will be moved down after the msg.City copy.)

If you have no house node this will create one.

If you have more than one house node it will throw an exception.
Reply With Quote
Reply

Tags
xml, xml child segments, xml error, xml segments

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:01 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation