A tricky & alternative solution to split string at specified delimiter.
Thanks to KuanChiang Lui to provide this Trick.
Scenario: There have a string value (Delimiter strings) that returned from a data source or response value from a web request (SOAP or REST) and would like to split it and store into a dictionary.
Example Input Text = “1,2,3,4,5,6,7,8,9,10”
Expected Output Dictionary = i"1","2","3","4","5","6","7","8","9","10"] |
Solutions: Check out the step by step below.
Pre-requisites: Create a Text Variable and set value with "1,2,3,4,5,6,7,8,9,10".
{Variable: String to Split} = 1,2,3,4,5,6,7,8,9,10
Step 1: Apply “Set Workflow Variables” action and configure to add XML node in between “String to Split”.
Step 2: Apply “Replace Substring in String” action and configure to replace the delimiter “,” with XML node.
The Output “String to Split” is becomes a valid XML as below.
<values> <value>1</value> <value>2</value> <value>3</value> <value>4</value> <value>5</value> <value>6</value> <value>7</value> <value>8</value> <value>9</value> <value>10</value> </values> |
Step 3: Apply “Query XML” action and configure to query the values into dictionary.
Result: Return the string in dictionary format
{Variable: Output in Dictionary} = "1","2","3","4","5","6","7","8","9","10"]
The enclosed attachment is the sample workflow that has been configured with steps above. You can import to Site workflow in Nintex Workflow Office 365.
Cheers!!!