web stats
Parse HTML tags inside Mirth - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-11-2016, 06:42 AM
vibinChander vibinChander is offline
OBX.2 Kenobi
 
Join Date: Jul 2015
Location: Chennai
Posts: 74
vibinChander is on a distinguished road
Send a message via Skype™ to vibinChander
Red face Parse HTML tags inside Mirth

Hi Guys,

I'm facing a problem here, I'm receiving a HTML tag based file in email, I want to remove all the html tags and get only the text in it. Is there any way i can remove all the <html> tags and parse the content inside mirth?. Im using mirth3.0.3 . Im posting my incoming sample data here.
Code:
<dl class="dl-vertical">
					<dt>Name</dt>
					<dd>xxxxxx</dd>
					<dt>Event</dt>
					<dd>yyyyyy</dd>
					<dt>MRN</dt>
					<dd>xxxx</dd>
					<dt>Date of Birth</dt>
					<dd>xxxxxxx</dd>
					<dt>Gender</dt>
					<dd>y</dd>
					<dt>Address</dt>
					<dd>1yyyyy, , yyyyyy, yyyy, yyyyyy</dd>
				</dl>
I want to get only the values, (i.e) xxxx,yyyy values removing the tags. Is it possible?
Reply With Quote
  #2  
Old 01-11-2016, 06:45 AM
callmeonnet callmeonnet is offline
Mirth Newb
 
Join Date: Apr 2015
Posts: 17
callmeonnet is on a distinguished road
Default

Hi,

You can make use of jsoup library. (Download from jsoup website)

Below the working solution for your problem.

importPackage(org.jsoup) // initialize package
var contents = FileUtil.read('E:\\1.txt'); // Read your html
var doc = Jsoup.parse(contents); // Parse and store in doc
var p= doc.select("dd").first(); // To take only 1st data
logger.info(doc.select("dd").get(0).text()); // To take only 1st data in array
logger.info(doc.select("dd").get(1).text()); // To take only 2nd data in array of doc selector

Let me know if you are facing issue

-
Arvind
HIT Security Professional
Reply With Quote
  #3  
Old 01-12-2016, 03:50 PM
obsessio obsessio is offline
OBX.3 Kenobi
 
Join Date: Mar 2015
Location: Turkey
Posts: 164
obsessio is on a distinguished road
Default

parse the value and replace with RegExp

Code:
<.\w+>|<*.*">
Reply With Quote
  #4  
Old 01-19-2016, 02:24 AM
vibinChander vibinChander is offline
OBX.2 Kenobi
 
Join Date: Jul 2015
Location: Chennai
Posts: 74
vibinChander is on a distinguished road
Send a message via Skype™ to vibinChander
Thumbs up Working Fine

Hi Arvind,

Thanks for the Script, this squence of Code works fine in solving my issue.
Reply With Quote
Reply

Tags
hl7v2, html, mirth3.0.3

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 09:10 PM.


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