web stats
Looping through XML Attributes - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-17-2017, 09:58 AM
cbarlow cbarlow is offline
OBX.1 Kenobi
 
Join Date: Sep 2015
Location: Missouri
Posts: 50
cbarlow is on a distinguished road
Default Looping through XML Attributes

Does anyone know how to loop through all Attributes of an XML tag? In doing some research, I found I can loop through them and get their values by doing ...

for each(Attribute in xmlNode.attributes())

however, I am unable to figure out how to get the attribute name. I have an XML document where I need to append a value to the front of every attribute name so I need to loop through them and cannot figure out how.

Thanks.
Reply With Quote
  #2  
Old 10-17-2017, 10:17 AM
cbarlow cbarlow is offline
OBX.1 Kenobi
 
Join Date: Sep 2015
Location: Missouri
Posts: 50
cbarlow is on a distinguished road
Default

I figured it out. This seems to work for me

var i = 0;
for each(var wAtt in xmlNode.patient.@*) {
channelMap.put(i,wAtt);
channelMap.put(i + '_name',wAtt.localName());
i++;
}
Reply With Quote
Reply

Tags
attribute, javascript, 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:08 PM.


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