Page 1 of 1

Conditional Node XML Decision

Posted: Fri Sep 08, 2023 11:29 am
by graham728
Hi,

Looking for a way to use the Conditional node to change the course of a workflow based on metadata in the XML it has just read.

The %s_xml_advertiser% field will either start with the characters CP or CB - I'm unsure what to put in the right-hand field for the node to either accept or reject and thus change the path the file is then sent down.

Re: Conditional Node XML Decision

Posted: Fri Sep 08, 2023 1:14 pm
by FranceBB
So if it starts with CP or CB is fine?

Step 1:
Read the XML

Image

Code: Select all

%s_myxmlfile% = $read("%s_original_path%\%s_original_name%.xml")
Step 2:
Read the advertiser value and save it in your variable "xml_advertiser"

Image

Code: Select all

%s_xml_advertiser% = $stripws($between("%s_myxmlfile%", "<Advertiser>", "</Advertiser>"))
Step 3:
Check if it starts with CP or CB

Image

Code: Select all

if %s_xml_advertiser% == CP* || if %s_xml_advertiser% == CP* Then
do something
else 
do something else
The whole workflow would be something like:

Image

Re: Conditional Node XML Decision

Posted: Sat Sep 09, 2023 10:17 am
by momocampo
Hi ,

Here is my method, I prefer to use regex to retrieve what you want.


advertiser.jpg
advertiser.jpg (75.24 KiB) Viewed 3339 times

Your variable %s_xml_advertiser% will be "CP" or "CB", just place a conditonal after the previous populate node

cond.jpg
cond.jpg (46.97 KiB) Viewed 3339 times

So, if "yes" -> CP
If "no" -> CB

Hope it helps.
B.