xml - Get node based on siblings value xpath query -


i want format nodes text in sibling node popularity less 8

<collection shelf="classics"> <movie title="the enemy" shelf="a">    <type>war, thriller</type>    <format>dvd</format>    <year>2001</year>    <rating>pg</rating>    <popularity>10</popularity>    <description>talk war</description> </movie> <movie title="transformers" shelf="b">    <type>science fiction</type>    <format>dvd</format>    <year>1980</year>    <rating>r</rating>    <popularity>7</popularity>    <description>science fiction</description> </movie>    <movie title="trigun" shelf="b">    <type>action</type>    <format>dvd</format>    <episodes>4</episodes>    <rating>pg</rating>    <popularity>10</popularity>    <description>quite bit of action!</description> </movie> <movie title="ishtar" shelf="a">    <type>comedy</type>    <format>vhs</format>    <rating>pg</rating>    <popularity>2</popularity>    <description>boring</description> </movie> </collection> 

so far using query is

/collection/movie[popularity[text() != '8' , text()!='9' , text()!=10]]/format/text() 

which gives me perfect results doesn't looks impressive ,when use < operator in xpath query gives invalid xpath expression

/collection/movie[popularity[text() &lt; 8]]/format/text() 

how use < operator desired results

any appreciated

you can try casting via number():

/collection/movie[popularity[number(text()) < 8]]/format/text() 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -