web stats
How do I pull this XML field into a mapped variable - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2012, 07:57 AM
akh2103 akh2103 is offline
Mirth Newb
 
Join Date: Jul 2011
Posts: 17
akh2103 is on a distinguished road
Default How do I pull this XML field into a mapped variable

I have an incoming message that is getting parsed into XML like this:

<PID>
<PID.1>
<PID.1.1>1</PID.1.1>
</PID.1>
<PID.2/>
<PID.3>
<PID.3.1>NumberOne</PID.3.1>
<PID.3.2/>
<PID.3.3/>
<PID.3.4/>
<PID.3.5>CODE~NumberTwo</PID.3.5>
<PID.3.6/>
<PID.3.7/>

I want to pull NumberTwo in a transformer and set it to a channel variable.

Based on previous experience with mirth, I would think that I would do something like...

Mapping: msg['PID']['PID.3']['PID.3.5']['PID.3.5.2'].toString() but this is throwing an error.

Can somebody help me out with this simple syntax issue? Thanks!
Reply With Quote
  #2  
Old 08-13-2012, 08:15 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Assuming your encoding characters are "^~\&", then your field repetition marker is "~", and your subcomponent marker is "&". So to retrieve "NumberTwo" (which is in the first component of the second repetition of PID.3, not the second subcomponent of PID.3.5), you need to check "Parse Field Repetitions" on the inbound protocol (Source Inbound if transforming on the source, Source Outbound if on the destination), and then use the following syntax:

Code:
msg['PID']['PID.3'][1]['PID.3.1'].toString()
Note that using that syntax is assuming that there are always at least two repetitions of PID.3. An ECMAError will be thrown if there aren't, so make sure to do proper validation, etc.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 08-13-2012, 09:35 AM
akh2103 akh2103 is offline
Mirth Newb
 
Join Date: Jul 2011
Posts: 17
akh2103 is on a distinguished road
Default

Thanks
Reply With Quote
Reply

Tags
mapping, syntax, xml

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 07:49 AM.


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