message.addChildMessage¶
Signature: message.addChildMessage(nodePath, childMessage)
Returns: void
Add the childMessage to the first node that matches nodePath.
Note
This method only applies to XML formatted messages.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | nodePath | the node path (XPath, HPath, Column ID, etc.) | |
| Message | childMessage | the child model to add |
Example¶
// Given an XML message like:
message = qie.createXMLMessage(
`
<people>
<person>
<name>Nate</name>
<age>30</age>
</person>
<person>
<name>John</name>
<age>41</age>
</person>
</people>
`
);
// And a child message model to insert:
var childMessage = qie.parseXMLString(
`
<person>
<name>Bob</name>
<age>52</age>
</person>
`
);
// Add the childMessage to the node matched by nodePath
message.addChildMessage(
"/people", // nodePath
childMessage // childMessage
);
// Resulting XML:
// <people>
// <person>
// <name>Nate</name>
// <age>30</age>
// </person>
// <person>
// <name>John</name>
// <age>41</age>
// </person>
// <person>
// <name>Bob</name>
// <age>52</age>
// </person>
// </people>