0

I want to get all the format nodes text in which its sibling node popularity is less than 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 about a 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 a 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 i am using the query is

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

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

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

how to use < operator to get the desired results

Any help will be greatly appreciated

1 Answer 1

1

you can try casting via number():

/collection/movie[popularity[number(text()) < 8]]/format/text()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.