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() < 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
Post a Comment