0

How to read a list of values from Mirth Channel XML's <mapping> element? I can use msg to read one value. But what if there are list of values? Example:

<patient>
    <name>names</name>
<patient>

If there is one value fornames defined, then simply performing <mapping>msg['patient']['name']</mapping> will return the value. But how to get only values if the names return more than one name? How to iterate and display in the same XML? I am doing Mirth for the first time and any help is appreciated.

Yogesh Ghimire
  • 432
  • 1
  • 8
  • 21

1 Answers1

0

I understand your question in this way.. so you mean if you receive the XML in this fashion

<patient>
    <name>names</name>
    <name>name1</name>
</patient>

then how to iterate and fetch only 'name' tags value. If my understanding is correct then place the below code in your source transformer.

var nameLen = msg['name'].length();
for(i=0;i<nameLen;i++){
    // Your Mapping Logic
    logger.debug(msg['name'][i].toString());
}
Vibin Guevara
  • 778
  • 10
  • 27