XPath: Select all nodes that DON'T contain certain subnodes
-
Hi! I need to select certain nodes that DON't have specific subnodes, i.e. Select all nodex x/y where there is no subnode x/y/a or x/y/b Example: blup test bla bla I'd appretiate all suggestions. Thanks in advance! Regards, Andre Loker
Hi Andre. Here's one approach - using a for-each to select only those x/y nodes that don't have a child a or child b node.
<?xml version='1.0' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<xsl:for-each select="x/y[not ((descendant::a) or (descendant::b))]">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>I hope that helps.
-
Hi Andre. Here's one approach - using a for-each to select only those x/y nodes that don't have a child a or child b node.
<?xml version='1.0' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<xsl:for-each select="x/y[not ((descendant::a) or (descendant::b))]">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>I hope that helps.