Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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 :)
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".
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>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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 :)
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".
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>
is working on a reply...