cancel
Showing results for 
Search instead for 
Did you mean: 

XPATH expression when the value has some trailing spaces

Former Member
0 Kudos

Hello All,

I am in PI 7.4 and writing a condition to determine interfaces based on the value coming in D_106.

The condition I am checking is (Xpath./p1:ASC850_004010/S_ISA/D_I06 = "1234      ")

The other condition is (Xpath./p1:ASC850_004010/S_ISA/D_I06 != "1234      ")

When the value coming in the message for D_106 is "1234      ", it always executing != "1234      " part.

I think there is something wrong I am doing.  Please let me know

thx

mike

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos

Hi Mike,

you can use the Xpath function normalize-space(string) to remove the leading or trailing spaces. refer the below link

XPath, XQuery, and XSLT Function Reference

the other option is to use hexadecimal value for space. refer the expression in below conversation

Locating the node by value containing whitespaces using XPath - Stack Overflow

regards,

Harish

Answers (3)

Answers (3)

nidhi_srivastava22
Active Contributor
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Michael

Please modify your condition like below

/p1:ASC850_004010/S_ISA/D_I06 ≈ 1234*

/p1:ASC850_004010/S_ISA[not(contains(D_I06,'1234      '))] EX

Then you will have the desired result.

Thanks,

Indrajit

Former Member
0 Kudos

Hi,

To make sure condition is failing due to trailing space(s) .Change the condition as below and remove the space in D_106 field value.

/p1:ASC850_004010/S_ISA/D_I06 = "1234".

If it is due to white spaces ,go through below link for different ways to fix.

xpath expression to remove whitespace - Stack Overflow



Regards

Venkat