Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nami Nasserazad 23 posts 43 karma points
    Jun 17, 2011 @ 11:20
    Nami Nasserazad
    0

    Intersection of two nodes in umbraco with XSLT

    Hi

    I have two nodes like this:

     

    <Block>
        <nodeId>
            2009
        </nodeId>
        <nodeId>
            2010
        </nodeId
    </Block>
    
    <News>
        <nodeId>
            2009
        </nodeId>
    </News>

    I would like to find whether Block and News have intersection in their children or not. For example for this sample I want to get true which means these two nodes have intersection. I really prefer to get this with one XSL (XPath) expression.

    Regards,

    Nami

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jun 17, 2011 @ 14:12
    Morten Bock
    0

    I'm going to assume that there is some sort of root elemnt around the shown xml. In that case, this should do the trick:

        <xsl:variable name="exists" select="root/Block/nodeId = root/News/nodeId" />
        <xsl:value-of select="$exists"/>

    Using the = operator will return true if there are matching nodes in the two node sets.

    http://zvon.org/comp/r/ref-XPath_1.html#Expressions~%3D

  • Nami Nasserazad 23 posts 43 karma points
    Jun 17, 2011 @ 17:20
    Nami Nasserazad
    0

    Thanx a lot. Simple nice solution.

Please Sign in or register to post replies

Write your reply to:

Draft