加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 当attibute不存在时,按属性选择xpath

发布时间:2020-12-16 08:05:47 所属栏目:百科 来源:网络整理
导读:简短问题: 我想选择所有不匹配属性的节点(@type!=’x’),而属性不存在(??)。 目前,我没有任何回报,因为其他节点根本没有任何属性。 背景: 我有一些XML请注意,有一个type =“feature”,但所有其他的没有’type’attr。 image type="feature"descripti
简短问题:
我想选择所有不匹配属性的节点(@type!=’x’),而属性不存在(??)。
目前,我没有任何回报,因为其他节点根本没有任何属性。

背景:
我有一些XML请注意,有一个type =“feature”,但所有其他的没有’type’attr。

<image type="feature"><description>X</description><url>media/designer_glass_tile_04.jpg</url><height></height><width/></image>
<image><description>Designer Glass 05</description><url>media/designer_glass_tile_05.jpg</url><height></height><width/></image>
<image><description>Designer Glass 06</description><url>media/designer_glass_tile_06.jpg</url><height></height><width/></image>
<image><description>Designer Glass 07</description><url>media/designer_glass_tile_07.jpg</url><height></height><width/></image>
<image><description>Designer Glass 08</description><url>media/designer_glass_tile_08.jpg</url><height></height><width/></image>

和XSL风格:

<div id="gallery">
            <div id="feature" >
                <xsl:apply-templates select="image[@type='feature']"/>
            </div>
            <div id="thumbs">
                <xsl:apply-templates select="image[@type!='feature']"/>
            </div>
        </div>

谢谢你的时间

以下代码将选择type属性不存在的所有节点:
select="image[not(@type)]"

在你的代码中添加这个逻辑。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读