Compare the current and next node names using XPATH

    In your XSL, if you need to test to see if the next element is named the same as the current one you can use the following piece of code to get the result using a combination of XPATH axes and the name() function.

    <xsl:if test="name(./following-sibling::*) = name(.)">
                <!-- Do something -->
    </xsl:if>

    This little test got me stumped for a good half an hour. Hopefully this helps some other people.

    This post was last modified on May 28, 2013 12:24 am

    Dom Sammut: Dom Sammut is a PHP / Node.js Web Developer from Australia with extensive experience in developing in and customising Laravel, Express, VueJS, WordPress, Symphony CMS, Craft CMS and Squiz Matrix.
    Related Post