Skip to content

source.getLastNode

Use when: You want to read values from the original incoming message before any mapping changes. If you need the modified message during mapping, use message.getLastNode.

Signature: source.getLastNode(nodePath)

Returns: String nodeValue - the value of the last node that matches the nodePath

Get the value of the last node that matches the nodePath.

Note

This method only applies to the following formatted messages: HL7, ASTM, CSV, DICOM, EDIFACT, Fxd Length, ISO 8583, JSON, Text, X12, XML.

Parameters

Type Name Description Default
String nodePath the node path (XPath, HPath, Column ID, etc.)

Example

 // Given an XML source containing multiple <person> elements with <age> values.
 /* source:
'<?xml version="1.0" encoding="UTF-8"?>' +
'<people>' +
'   <person>' +
'      <name>Nate</name>' +
'      <age>30</age>' +
'   </person>' +
'   <person>' +
'      <name>John</name>' +
'      <age>41</age>' +
'   </person>' +
'   <person>' +
'      <name>Jane</name>' +
'      <age>52</age>' +
'   </person>' +
'</people>'
 */
 // Retrieve the value of the last node that matches the nodePath.
 var lastAge = source.getLastNode('/people/person/age'); // expected: "52"