Create a channel that uses a DB as the source. Add your query to the SQL Stmnt section:![](https://www.qvera.com/kb/?qa=blob&qa_blobid=10328150880176390091)
Set up a new output message as XML:
![](https://www.qvera.com/kb/?qa=blob&qa_blobid=17168079814918990052)
Create a new mapping function for your custom script.
![](https://www.qvera.com/kb/?qa=blob&qa_blobid=14564410021752051757)
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);
message.formatXML(3);
Because database sources provide a CSV message, the CSV <-> HL7sandbox also has useful examples; just change HPATH and HL7 to XPATH and XML.