web stats
XML Data Direct Accessor - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 03-04-2016, 07:35 AM
smetz02 smetz02 is offline
Mirth Newb
Join Date: Feb 2013
Posts: 23
smetz02 is on a distinguished road
Default XML Data Direct Accessor

Hi everyone,

JavaScript allows for direct filtering and accessing of data, without needing to use an iteration statement (for, for each), by using a dotted notation, such as:

var m = x.car.(color != "silver").model

Using the XML below, the above statement will return all of the "model" nodes of every parent "car" where the color is not silver.

This dotted notation can't work with HL7 XML because there are dots all over the place in the node name. Either the dots needs to be escaped, which I haven't been able to do, or you have to try the bracketed notation, which doesn't seem to work either.

Is there a way to do what I've done below with HL7 bracketed notation or a way to use the dotted notation by escaping the dots in node names?

Sample XML which allows for dotted notation
var x = new XML(

Different tests:
var m = x.car.(color == "silver").model;
returns: <model>Civic</model><model>Jetta</model>

var m = x.car.(color != "silver").model;
returns: Focus

var m = x['car'](['car']['color'] == "silver")['model'];
throws error

var m = x['car'].(['car']['color'] == "silver")['model'];
returns nothing

var m = x['car'].(['color'] == "silver")['model'];
returns nothing

Steve Metz
Reply With Quote
Old 03-04-2016, 08:14 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road

To clarify, that ".(foo == 'bar')" syntax is part of E4X, not JavaScript itself.

You can use a function in there:

var m = x.car.(function(){return new XML(this)['color'] == 'silver'}()).model;
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.

Last edited by narupley; 03-04-2016 at 09:15 AM.
Reply With Quote
Old 03-04-2016, 09:13 AM
smetz02 smetz02 is offline
Mirth Newb
Join Date: Feb 2013
Posts: 23
smetz02 is on a distinguished road

Thanks. Works perfectly.
Reply With Quote

e4x, ecma script, 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 02:40 PM.

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