Skip to content

qie.createXMLMessage

Signature: qie.createXMLMessage(template, encoding*)

Returns: XML Message message - the newly created message object

Replace the current message with an empty XML formatted message based on the XML template.

Note

You must specify at least the root node (and only 1 root node) in your XML template in order to create a valid XML message.

Note

The return value MUST ALWAYS be assigned to the bound-in message object.

Note

encoding is optional. When not specified, {source encoding} is the encoding set on the channel's source node, or the encoding of the current message when the channel has none.

Parameters

Type Name Description Default
String template the XML document template
String encoding* (optional) the character encoding for this message {source encoding}

Example

// Example: create an XML message from a template.
// Note: the XML prolog cannot be specified in the template itself.

var xmlTemplate = `
<greeting>
    <message>Hello, world!</message>
    <language>English</language>
</greeting>
`;

message = qie.createXMLMessage(
    xmlTemplate,   // template: XML document template (single root node required)
    'UTF-8'        // encoding: character encoding
);

// Add the XML prolog after creating the message
message.addProlog('<?xml version="1.0" encoding="UTF-8"?>');