【发布时间】:2018-12-30 16:46:27
【问题描述】:
<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>
在上面的代码段中,我想获取描述元素包含子字符串函数的段的标题属性。我尝试使用包含返回布尔值并期望参数为字符串的函数。我尝试了一些 Xpaths 的东西,但效果很好,我知道答案是 collection/movie[contains(description,'bit')]/@title
由于 contains 只返回布尔值,在上述情况下它是如何工作的。请澄清
【问题讨论】: