Skip to main content
Nintex Community Menu Bar

Working with extracted XML - Parsing out & concatenating back together

  • June 12, 2018
  • 15 replies
  • 42 views

Forum|alt.badge.img+6

This question is a follow-up to a previous question on how to pull out xml data for a multi-line text with using append changes to text.  I have been able to create a workflow which will pull the xml data, but the data is still kind of messy.  I want to continue building onto my workflow to  take this data, strip out the non-needed text, concatenate the outputs back together and store results in another field.  I know to concatenate the fields back together I need to use Build String, but I'm not sure what to use when stripping out the unneeded text.

Again, the method I'm using (multi-line append changes to text field) is required per my line of work.  I need to pull the data out and load into another field for easy extraction into excel.

Below are the results of my Query XML step.  I have 3 outputs which will need to be 'prettied-up' and then concatenated back together before loading into another field.

Any help would be greatly appreciated! 

15 replies

Forum|alt.badge.img+14
  • Scholar
  • June 13, 2018

I guess you mean toclear  HTML markups from output3 of your screenshot...

and I assume you stored output3 into a collection variable.

then actually you do not need to split&put together anything. you can remove all the markups with single regular expression operation

use regexp pattern like 

(<div class="ExternalClass[0-9A-F]+">|</div>|<p>|</p>)

216573_pastedImage_5.png

note output of a regular expression action is a text. if you need to turn it back into a collection, use one another regular expression action to split text by semicolons into a collection

use simple regexp pattern like 

;

216572_pastedImage_4.png


Forum|alt.badge.img+6
  • Author
  • June 14, 2018

Good Morning Marian,

Thank you so much!!!  That is super helpful!!!  I also need to strip out the extra text in Output2, so only the user's name is left.  Currently, Output 2 displays UserName, system ID, user email address, UserName.  I only need the User's name (once).  What is the easiest way to strip out all the other data and just leave the text inside the Red circle in my screen print below?

Thank you!


Forum|alt.badge.img+14
  • Scholar
  • June 19, 2018

try with following regular expression 

d+.*?,#,#

Forum|alt.badge.img+6
  • Author
  • June 28, 2018

Hi Marian,

Sorry I did not respond for a bit, got pushed onto another project that took precedence.  Back to getting this resolved now.

I added in the last expression you sent to break out the Editor.  It is working, but I am left with an extra comma inbetween the last and first name: lastname,, firstnameIs there a way to be able to remove the extra comma?

Additionally, I am able to confirm the text is being broken out appropriately as well!

Thank you!!

Christine


Forum|alt.badge.img+14
  • Scholar
  • June 29, 2018

I don't see this in my env. don't you have that commas originally in your user names?

either way, you can remove commas with an extra regular expression action, or build string action with replace() function.


Forum|alt.badge.img+6
  • Author
  • June 29, 2018

our user names are separted in our system by 1 comma, but when extracting the data out, there are 2 commas.

What is the format for the regular expression action that will remove one of the commas?  I tried it on my own, but I was not successful.

Thank you.


Forum|alt.badge.img+6
  • Author
  • June 29, 2018

Hi Marian,

Is there an expression to change the format of the date/time?  My date/time is coming out like this: 2018-06-18T18:18:40Z

Is there a way to change the time format to be 12hr format w/ AM/PM? 

Thank you!!


Forum|alt.badge.img+14
  • Scholar
  • June 29, 2018

simply replace doubled commas with single one

216817_pastedImage_1.png


Forum|alt.badge.img+14
  • Scholar
  • June 29, 2018

what would you like to do with the date?

most of the actions/controls will accept it in this way


Forum|alt.badge.img+6
  • Author
  • June 29, 2018

The date can stay in the same format, I was looking to remove the 'T' and then reformat the time to be 12HR format instead of 24HR format.  Also, remove the 'Z' at the end of the string.


Forum|alt.badge.img+6
  • Author
  • June 29, 2018

I was able to get the date/time into a format I needed by using the DateFormat Funtion in the Build String action.

I did come across a new scenario with my comments.  The comment had quoted text in,...so and so said, "....."...the raw XML has a <span> tag in it.... ;<span style="color&#58;#1f497d;font-family&#58;&quot;calibri&quot;,sans-serif;font-size&#58;11pt;">

I have noticed that it prints out the text up to the " and any text inside the <span> tag is not being returned.  Additionally, the next comment also does not print out...the date/time of the next comment prints, but the comment itself does not.  The second comment has nothing special with it (not inside <span> tag or anything).

Is there a way to resolve this?  The field I'm storing the data in, is a multi-line text field, with 20 lines of editing allowed.

Thank you,


Forum|alt.badge.img+14
  • Scholar
  • July 2, 2018

it would be possible (eg) to write  regular expression that would remove span tag.

but later on you will find another HTML tag used. then you'll notice some characters are being stored with their entity or numeric interpretation. etc., etc.

finally you'll end up building full html to plain text converter.

if it is required that comments are in rich text (html) you should then approach/process it as html.


Forum|alt.badge.img+6
  • Author
  • August 17, 2018

Hi Marian,

I have come across a new wrench I'm hoping you can help me with!  How can you remove special characters from within the actual Text?  Example, Comment has T&Cs...the XML displays it as Tamp;Cs. 

The regular expression to split out each comment into the collection variable is getting confused and separating the Cs as a separate comment.

How can I remove say, ; from within the actual text, without removing it from the end of each comment string?


Forum|alt.badge.img+14
  • Scholar
  • August 20, 2018

Example, Comment has T&Cs...the XML displays it as Tamp;Cs. 

that's normal XML feature.

have a look on XmlDecode() and XmlEncode() functions


Forum|alt.badge.img+6
  • Author
  • August 21, 2018

Thank you Marian!!  That resolved the issue, it appears!

I added the following to the Input Text box in my first regular expression after the XML Query action:

fn-XmlDecode({WorkflowVariable:varRawComments})

Thank you so much!