Don't get lost: Training » Integration Cookbook » XML Writer » Referencing the Value of a Repeating Node

Referencing the Value of a Repeating Node

SCENARIO

We need to obtain the both the values contained in the ReferenceNumber nodes. I.e. The values are enclosed in the node itself.

This differs from other examples the values being queried are nested within nodes that are children to the repeating node.

SOLUTION

Assuming that we have a parent transaction type where the XPath of the Transaction is MasterBillOfLading and an initial XPath of MercuryGate. Both marked above.

Transaction XPath

Plan/Events/Event[@type='Pickup']/Shipments/ReferenceNumbers/ReferenceNumber

The ReferenceNumber itself node is included in the XPath. This is because the ReferenceNumber node itself is the repeating node. See image above.

Field XPath

The field XPath is just a simple dot or ‘.’ (minus the quotes), and this is XPath’s shorthand way of referencing the current node.

If the Transaction XPath was specified only to the ReferenceNumbers node and the Field XPath was ReferenceNumber, you would only pick up the first value as there is only a single ReferenceNumbers node.