Q:

Displaying Subnode content on parent node in Umbraco

I've been having a lot of trouble figuring this out.
What I want is a FAQ page that displays all the questions and answers on the same page. It gets the content from the questions and answers from subnode content.
So for example my tree looks like this:

FAQ

Question1
Question2
Question3

I want the template on FAQList to list the question and answer data from Question1...2... and 3 on the same page.
Every time I try to find examples of this being done I can only find examples that list the subpages as links. I don't want to link to the subpages. I want to actually print the content from them onto the parent page. Is that possible?
This is my attempt at it:
<xsl:for-each select="$currentPage/node">

    Question: <xsl:value-of select="data [@alias = 'question']"/><br/>

    Answer: <xsl:value-of select="data [@alias = 'answer']"/><br/>

</xsl:for-each>

But I had no results. Help me out here. I'm banging my head on this.

A:

It all depends on the version of Umbraco you're running. There's a lot of documentation out there that refers to a much earlier version of Umbraco and simply won't work on more recent versions.
Assuming the document type alias of your questions is called 'FaqItem' and assuming that this XSLT is run on the respective content node (i.e. $currentPage is your FAQ parent node), you can use the following:
If you're using < Umbraco 4.5.1
<xsl:for-each select="$currentPage/child::node[@nodeTypeAlias='FaqItem']">
    Question: <xsl:value-of select="./data[@alias='question']"/><br/>
    Answer: <xsl:value-of select="./data[@alias='answer']"/><br/>
</xsl:for-each>

If you're using >= Umbraco 4.5.1
<xsl:for-each select="$currentPage/FaqItem">
    Question: <xsl:value-of select="./question"/><br/>
    Answer: <xsl:value-of select="./answer"/><br/>
</xsl:for-each>

For future reference
If you're familiar with XPath and want to figure out how Umbraco has stored the data, or to help with debugging. Look for a file called Umbraco.config (typically found in ~/App_Data/). This is the cached XML that all XSLTs will read from. Posting the relevant snippet from this file into your [Stack Overflow] question will increase the speed and chances of getting a response, as XSLT contributors will be able to help and not just Umbraco contributors.

