Reputation: 317
<collection>
<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>
In the above code segment,I want to get the title attribute for the segment where the description element contains a sub-string function.I tried to use contains functions which returns Boolean and expects a string for the argument. I tried something few Xpaths but dint work and got to know the answer is collection/movie[contains(description,'bit')]/@title
Since contains returns only Boolean value, how does it work in the above case.Please clarify
Upvotes: 0
Views: 92
Reputation: 49744
It's got nothing to do with contains()
specifically, [...]
simply defines a predicate, with which to filter things. So tag[boolean-expression()]
will return to you exactly those tag
s for which boolean-expression()
returns true()
(or to be more precise: a value that can be converted to true()
).
Upvotes: 2