【发布时间】:2015-12-18 02:12:36
【问题描述】:
我想获取其兄弟节点流行度小于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>
到目前为止,我使用的查询是
/collection/movie[popularity[text() != '8' and text()!='9' and text()!=10]]/format/text()
这给了我完美的结果,但它看起来并不令人印象深刻,当我在 xpath 查询中使用
/collection/movie[popularity[text() < 8]]/format/text()
如何使用
任何帮助将不胜感激
【问题讨论】:
标签: xml xpath xpathquery