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

简短问题:
我想选择所有不匹配属性的节点(@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)]"

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

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念