Copied to clipboard

Flag this post as spam?

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


  • Brian Juul Andersen 44 posts 98 karma points c-trib
    Nov 11, 2010 @ 13:53
    Brian Juul Andersen
    0

    Getting attribute value from node selected by another attribute.

    I got the following code snippet:

     

                  <xsl:variable name="media" select="umbraco.library:GetMedia($nyhedsbilled, 0)" />
                  <textarea cols="40" rows="20">
                    <xsl:copy-of select="$media/imageCrop/crops" />
                  </textarea>

     

    .. which gives this result:

    <crops date="29/10/2010 14:17:59">
    <crop name="NyhedPreview" x="11" y="0" x2="90" y2="60" url="/media/4967/lille01_NyhedPreview.jpg" />
    <crop name="GalleriPreview" x="11" y="0" x2="90" y2="59" url="/media/4967/lille01_GalleriPreview.jpg" />
    <crop name="Galleri800x600" x="10" y="0" x2="90" y2="60" url="/media/4967/lille01_Galleri800x600.jpg" />
    </crops>

     

    and that is fine but what I´m trying to get is the url value from the <crop>-node where the name attribute is 'NyhedPreview' so I thought I might try something like this:

     

    <xsl:copy-of select="$media/imageCrop/crops/crop[@name='NyhedPreview'][@url]" />

     

    but that returns the correct <crop>-node with all attributes ???

     

    What am I doing wrong here ?

  • Sean Mooney 131 posts 158 karma points c-trib
    Nov 11, 2010 @ 14:31
    Sean Mooney
    0

    You are close, try this:

    <xsl:value-of select="$media/imageCrop/crops/crop[@name='NyhedPreview']/@url" />

     

  • Brian Juul Andersen 44 posts 98 karma points c-trib
    Nov 11, 2010 @ 14:41
    Brian Juul Andersen
    0

    Yep ! That was it !

     

    Thank you Sean

Please Sign in or register to post replies

Write your reply to:

Draft