Copied to clipboard

Flag this post as spam?

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


  • Michael Falch Madsen 70 posts 92 karma points
    Nov 10, 2010 @ 15:41
    Michael Falch Madsen
    0

    Child nodes

    Here my case:

    I have a page with recipes where all ingredients are child nodes.

    The user adds a recipe to a shopping list which is stored in a javascript cookie.

    I the fetch the cookie en my xslt and for-each the selections. All that works as expected.  The problem is with the ingredients.

    So how do I access child nodes?

     

    This is what i have so far:

    <xsl:for-each select="umbraco.library:Split(umbraco.library:RequestCookies('indkoebsliste'),'-')/value">
        <xsl:if test=".!=''">
          <xsl:variable name="page" select="umbraco.library:GetXmlNodeById(.)"/>
          
          <xsl:for-each select="umbraco.library:GetXmlNodeById(.)">
            <ul class="opskrift">
              <xsl:if test="position() = 1">
                <li><b><xsl:value-of select="./titel" /></b></li>
              </xsl:if>           
              <li><xsl:value-of select="./maengde"/><xsl:value-of select="./tekst"/></li>

              <xsl:for-each select="umbraco.library:GetXmlNodeById(.)/descendant::* [@isDoc]">
                TEST<xsl:value-of select="$currentPage/@nodeName"/>
              </xsl:for-each>

            </ul>
          </xsl:for-each>
          
          <!-- <xsl:copy-of select="umbraco.library:GetXmlNodeById(.)"/> -->
        </xsl:if>
      </xsl:for-each>


    Appreciate all the help I can get :)

  • Jeff Grine 149 posts 189 karma points
    Nov 10, 2010 @ 17:19
    Jeff Grine
    0

    If the ingredients are children of the current node, then you just need to select the children in the inner for-each. No need to GetXmlNodeById again. Something like select="/ingredients".

  • Michael Falch Madsen 70 posts 92 karma points
    Nov 10, 2010 @ 20:49
    Michael Falch Madsen
    0

    You were right :) Thank you were much for saving me a headache

     

    Here whats worked

      <xsl:for-each select="umbraco.library:Split(umbraco.library:RequestCookies('indkoebsliste'),'-')/value">
        <xsl:if test=".!=''">
          <xsl:variable name="page" select="umbraco.library:GetXmlNodeById(.)"/>
          
          <xsl:for-each select="umbraco.library:GetXmlNodeById(.)">
            <ul class="opskrift">
              <xsl:if test="position() = 1">
                <li><b><xsl:value-of select="./titel" /></b></li>
              </xsl:if>          

              <ul>
                <xsl:for-each select="./descendant::* [@isDoc]">
                  <li>
                    <xsl:value-of select="maengde"/>
                    <xsl:value-of select="tekst"/>
                  </li>
                </xsl:for-each>
              </ul>


            </ul>
          </xsl:for-each>
          
     
        </xsl:if>
      </xsl:for-each>

Please Sign in or register to post replies

Write your reply to:

Draft