cancel
Showing results for 
Search instead for 
Did you mean: 

checking if there is an XML element after the root

Former Member
0 Kudos

hello experts

I have an XML that some time will have an element under the root, and some time not.

for example:

<Asset>

<PolicyPlan />

</Asset>

or if there is an element with data

<Asset>

<PolicyPlan >

<ID="1">

</PolicyPlan >

</Asset>

I would like to know if I can in the XI to check if there is an element under PolicyPlan, and if so, return its value (in this case 1) and if not return an empty string.

if it can be done in XI, or there is a code that need to be written as a new function, help will be appreciated.

Thanks

Kfir

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I hope you can achieve this with "exists" node function.

Experts, correct me If I am wrong.

Regards

Bhanu

Intelligroup.

Former Member
0 Kudos

this is what I did, but it always return 2 parameters.

appreciate if you can define the exact solution

(what node go to where)/

X->exists->/???????

henrique_pinto
Active Contributor
0 Kudos

as stefan said, just use:

ID -> MapWithDefault -> Target

And in MapWithDefault function, use an empty string as the defaut value.

Regards,

Henrique.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Please try to do the following mapping.

Map the source to exist function, The output of exist has to send to if conditiond and the output of if condition to the target.

Thanks,

Kiran.

stefan_grube
Active Contributor
0 Kudos

In mapping you can use the function

mapWithDefault.

This returns the original value if available, otherwise the default value, for example an empty string.

Regards

Stefan