How to extract embedded XML-encoded data from an XML document

Document created by Adam Arrowsmith Employee on Dec 6, 2013
Version 1Show Document
  • View in full screen mode
Some applications may return XML data that essentially contains an XML document embedded within another XML document, like this:

   <details>&lt;Result action=&quot;CREATE&quot; recordtype=&quot;CUSTOMER&quot;&gt;&lt;ErrorMessage&gt;Duplicate customer name found.&lt;/ErrorMessage&gt;&lt;/Result&gt;</details>

With the <details> element, note how the embedded XML's tags are XML-encoded with "&lt;" and "&gt;" codes instead of the usual angle brackets. If you need to get the values from the embedded XML to use in a map or decision step for example, how should you parse those values?
The solution is to extract the embedded XML using a Message step.

1. Use a Message step to arbitrarily replace the current document data with the value from the <details> element. This would be done right after the Connector step that returned the data.


This step automatically decodes the data to normal XML tags so now the document data will look like this:

<Result action="CREATE" recordtype="CUSTOMER"><ErrorMessage>Duplicate customer name found.</ErrorMessage></Result>

Tip: If you need to reference any of the values from the original response XML such as <requestid> or <status> in this example, use a Set Properties step to store them in dynamic document properties before this Message step.

2. Create a new XML profile that matches the embedded XML. You can either configure the profile elements manually or temporarily save the output of the Message step to a file and use the profile import feature to automatically create the elements.

3. Continue with the rest of your process logic referencing the embedded data with the new profile as you would normally.
2 people found this helpful