Copied to clipboard

Flag this post as spam?

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


  • daxu 22 posts 28 karma points
    Feb 25, 2009 @ 23:44
    daxu
    0

    how to find root's child with specific nodename?

    Hi,

    I am very new to xslt.

    In my site, I have home as root, then under it I have peoples which contain people.
    I have Projects which contain project type.

    Home
    -peoples
    -john
    -peter
    -projects
    -project 1
    -project 2

    When I am on page project 1, how can I retrieve the a list of people under peoples?
    I tried /homes/peoples/ but it doesn't work.

    Can someone help?

    Many Thanks

    Jerry


  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 26, 2009 @ 08:36
    Dirk De Grave
    1

    Hi,

    Have a look at a short introduction of xslt xpath axes and their shortcuts at http://umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts

    In your case, you'll need to traverse up the tree until you find a node with name = 'peoples' and list all child nodes from there...

    [code][/code]

    or

    [code][/code]

    Above snippet will yield results if you have the following structure:

    Home
    -peoples
    --john
    --peter
    -projects
    --project 1
    --project 2

    (At least I'm assuming that this is/should be the tree structure).

    Second snippet is much safer as it can rely on the alias of the document type rather than looking for the name (which can always be changed)

    Hope this helps.

    Regards,
    /Dirk


Please Sign in or register to post replies

Write your reply to:

Draft