web stats
Extract CDATA text - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-01-2012, 10:29 AM
whmurray whmurray is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 14
whmurray is on a distinguished road
Default Extract CDATA text

So this should be easy. I have searched for forums and can't seem to come up with what is probably the obvious....

I am build a JSON string and want to return it in an xml response, so it seems best to wrap the JSON in a CDATA element. No problem. I also have cases where I will need to process CDATA elements coming in.

So, given this XML:
Code:
<JSON>
     <JSONText>
          <![CDATA[some text here]]>
     </JSONText>
</JSON>
How do I get out just the "some text here" part.
I am currently doing:
Code:
var theJsonText = new XML(vmResponse.getMessage()).JSONText;
which gives me "<![CDATA[some text here]]>". How do I get the content of the CDATA???
Reply With Quote
  #2  
Old 05-01-2012, 11:25 AM
whmurray whmurray is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 14
whmurray is on a distinguished road
Default

I can get my desired result with the following:

Code:
var theJsonText = new XMLList(String(new XML(vmResponse.getMessage()).JSONText)).toString();
Seems like a lot of overhead. Is there something simpler???
Reply With Quote
Reply

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 -7. The time now is 04:09 AM.


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