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

Questions about XML that are not covered by the other forums should go here.
mariomueller
Posts: 30
Joined: Wed Feb 14, 2018 3:27 pm

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

Post 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
mariomueller
Posts: 30
Joined: Wed Feb 14, 2018 3:27 pm

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

Post by mariomueller »

I got it:

/ABC/XYZ/text()=('9'or '293' or'305' or '332')
mariomueller
Posts: 30
Joined: Wed Feb 14, 2018 3:27 pm

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

Post 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
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu »

Hi,

Maybe this StackOverflow post will help:

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

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mariomueller
Posts: 30
Joined: Wed Feb 14, 2018 3:27 pm

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

Post 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
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

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

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply