parsing - XQuery: extract number from string to use in comparison -


i new xquery, , frankly find learning curve incredibly steep.

i have xml structure looks this:

<root>     <product>         <size>500 units</size>     </product>     <product>         <size>1000 units</size>     </product>     <product>         <size>unlimited units</size>     </product> </root> 

i need write xquery statement returns nodes numerical value in size less 1000. somehow need determine numerical value (ignoring text) perform 'le' operation assume.

on top of this, there possibility node have no digits @ (e.g. 'unlimited units'), in case needs treated having value of 1000000.

is there way this? i've tried various combinations of fn:replace(blah, '\d', '') , casting xs:int, can't seem work.

any guidance appreciated.

use xpath 1.0 expression:

/root/product[not(number(substring-before(size, ' ')) >= 1000)] 

as know well, xpath subset of xquery, above xquery expression.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -