Page 1 of 1

XPATH 1.0 workaround for /ABC/XYZ/text()=('9','293','305','332')

Posted: Thu May 24, 2018 11:07 am
by mariomueller
Hi all,

the following expression works only in XPATH 2.0

Code: Select all

/ABC/XYZ/text()=('9','293','305','332')
Is there any workaroud to do this in XPATH 1.0?

Thanks
Regards
Mario

Re: XPATH 1.0 workaround for /ABC/XYZ/text()=('9','293','305','332')

Posted: Thu May 24, 2018 11:12 am
by mariomueller
I got it:

/ABC/XYZ/text()=('9'or '293' or'305' or '332')

Re: XPATH 1.0 workaround for /ABC/XYZ/text()=('9','293','305','332')

Posted: Thu May 24, 2018 11:52 am
by mariomueller
Sorry, that does not work.
The expression with the ORs does always return true, although the value in the XML is totally different.

Could anybody please help?

Regards
Mario

Re: XPATH 1.0 workaround for /ABC/XYZ/text()=('9','293','305','332')

Posted: Thu May 24, 2018 11:57 am
by Radu
Hi,

Maybe this StackOverflow post will help:

https://stackoverflow.com/questions/481 ... -of-values

Regards,
Radu

Re: XPATH 1.0 workaround for /ABC/XYZ/text()=('9','293','305','332')

Posted: Thu May 24, 2018 12:41 pm
by mariomueller
Hi Radu,

thanks for the hint.

The XPATH has no syntax error and works with XPATH1.0 :

Code: Select all

contains(/M_UTILMD/G_SG2/S_NAD[D_3035='MS']/C_C082/D_3055/text(), '293')
But - asuming the value in the XML would be X293X, the expression return true although 293 is not X293X
It is just a contains, not an equals :-(

Any other ideas?
Regards
Mario

Re: XPATH 1.0 workaround for /ABC/XYZ/text()=('9','293','305','332')

Posted: Thu May 24, 2018 12:47 pm
by Radu
Hi Mario,

Right, that's why that post on StackOverflow suggested adding those spaces between the tokens in the string, to avoid such cases.

Regards,
Radu