How to read DB table value and create an XML using custom logic?

0 votes
asked Apr 28, 2021 by deepthi-a-5184 (240 points)

1 Answer

0 votes
Best answer

Create a channel that uses a DB as the source.  Add your query to the SQL Stmnt section:


Set up a new output message as XML:

Create a new mapping function for your custom script. 


Here is some example code that will add the data from 'DBColumn1' of the source query into a <DBColumn1> XML node:

var value = source.getNode('DBColumn1');
message.setNode('/root/DBColumn1', value);


Because database sources provide a CSV message, the CSV <-> HL7sandbox also has useful examples; just change HPATH and HL7 to XPATH and XML. 

answered Apr 28, 2021 by jon-t-7005 (7,990 points)
selected Apr 29, 2021 by deepthi-a-5184