Copied to clipboard

Flag this post as spam?

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


  • John Teglmand 8 posts 29 karma points
    Jul 21, 2011 @ 11:09
    John Teglmand
    0

    Umbraco 4.7 - umbraco.library:GetXmlNodeById

    Hi

    I want to use a variable to fetch some content from an element.

    From a macro I get the name of the data I want to get and a Node ID, and this is OK

    A1:ukMetalTekst
    ID:1161

    Then I try to get the content of "ukMetalTekst" (A) from the node "1161" (ID)

    Z1 show all data from the node, 
    Z2 show nothing
    Z3 show nothing

    --- xslt code ---- 

    <xsl:variable name="A1" select="/macro/A1"/>
    <xsl:variable name="Node" select="/macro/Node"/>

    A1:<xsl:value-of select="$A1"/><br />
    ID:<xsl:value-of select="$Node"/><br />

    <xsl:if test="$Node != ''">
      Z1:<xsl:value-of select="umbraco.library:GetXmlNodeById($Node)" /><br />
      Z2:<xsl:value-of select="umbraco.library:GetXmlNodeById($Node)/data [@alias='ukMetalTekst']" /><br />
      Z3:<xsl:value-of select="umbraco.library:GetXmlNodeById($Node)/data [@alias=$A1]" /><br />
    </xsl:if>

    --- the output is: ---

    A1:ukMetalTekst
    ID:1161
    Z1:20101160Alle Antagelser (DK)Alle Antagelser (UK)Præmieret værker (DK)Præmieret værker (UK)
    Z2:
    Z3:

    Z1 is the node i xml format

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 21, 2011 @ 12:12
    Dirk De Grave
    0

    Hi John,

    v4.7 uses the new xml schema by default unless you override this in the config.

    So, your fetching should look like:

    <xsl:if test="$Node != ''">
      Z1:<xsl:value-of select="umbraco.library:GetXmlNodeById($Node)" /><br />
      Z2:<xsl:value-of select="umbraco.library:GetXmlNodeById($Node)/ukMetalTekst" /><br />
      Z3:<xsl:value-of select="umbraco.library:GetXmlNodeById($Node)/* [local-name()=$A1]" /><br />
    </xsl:if>

    Hope this helps.

    Regards,

    /Dirk

  • John Teglmand 8 posts 29 karma points
    Jul 21, 2011 @ 12:31
    John Teglmand
    0

    works perfect - Many thanks for your help

Please Sign in or register to post replies

Write your reply to:

Draft