how do i choose between a same name element with different attributes?

Perhaps you could do something simpler:


        <name lang="en">Red</name>
        <name lang="en">Square</name>

XSLT 1.0

<xsl:stylesheet version="1.0" 
<xsl:output method="text" />

<xsl:template match="parent">
    <xsl:text>Color: </xsl:text>
    <xsl:value-of select="item[name='Col']/name[@lang='en']"/>
    <xsl:text>&#10;Shape: </xsl:text>
    <xsl:value-of select="item[name='Sha']/name[@lang='en']"/>



Color: Red
Shape: Square

Note that the values in my XML example contain no quotes.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top