Is it possible to return the raw XML from a Read XML step in workflow?
For example, I've attached how the XPath tester returns online for a simple sample XML. Then how it returns in the LF Workflow step.
Is it possible to return the raw XML from a Read XML step in workflow?
For example, I've attached how the XPath tester returns online for a simple sample XML. Then how it returns in the LF Workflow step.
I haven't done it with XML, but I have done this exact kind of thing with JSON.
In that case, I took all the first-level children of the root and returned "All matches as a multi-value token"
Then, I put that result token in a For Each Value loop. Inside the loop, I had a second ReadJSON activity that read the current value of the loop to extract the child values.
UPDATE: I played around with it a bit and it might not be possible to do the same with XML after all. Even in the test window I can get children back in JSON format, but with XML it just strips away all the formatting.
Read XML is going to give you the "interpreted" values.
If you want the raw XML received in the response then you want to look at the result Content token directly instead of opening it in a Read XML.
What the XPath tester is showing you is how it interpreted the XML because you selected the option to return the XML item type, but this is only meant for testing.
Workflow is giving you the actual values returned by XPath expressions.
Thank you Jason for the reply.
To give a little more background on our use case, we are basically handling an XML result coming back from a web request so there is no content file itself. I am looking to include the XML elements in the multi value array because ultimately this will end up as HTML in an Email.
For example, the response includes a <table> tag and <tr>/<td> tags. These are ALL being stripped by the Read XML step, not just the outer table tag.
Given our use case, it sounds like Read XML is not a usable method. Do you have any alternative recommendations for parsing XML and retaining the raw XML?
Let me clarify, when you select the "Content" token for the ReadXML activity, that token contains the raw XML. I suppose I'm not really clear on why you would want to both parse the XML values and keep it in a raw format.
Attached is a sample XML which will hopefully give some additional insight into our use case. I was hoping to pass this result into the Read XML step and create a multi value token where each element is the contents of /Records/Record/*. In this case, a two element array with the raw Record XML. Then I would use a For Each Value to iterate through the array, and another Read XML to parse the Emails tag, Contact Name and HtmlCode to send the email and include the information. Rinse, repeat.
Let me know if you have any other thoughts. Thanks again Jason.
I haven't done it with XML, but I have done this exact kind of thing with JSON.
In that case, I took all the first-level children of the root and returned "All matches as a multi-value token"
Then, I put that result token in a For Each Value loop. Inside the loop, I had a second ReadJSON activity that read the current value of the loop to extract the child values.
UPDATE: I played around with it a bit and it might not be possible to do the same with XML after all. Even in the test window I can get children back in JSON format, but with XML it just strips away all the formatting.
Thank you Jason! The JSON recommendation looks promising based on some testing this morning so that's the direction we'll head here.