Copied to clipboard

Flag this post as spam?

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


  • Chuck 71 posts 69 karma points
    Nov 16, 2011 @ 17:07
    Chuck
    0

    Nodefactory Ancestor at Level

    Using Nodefactory I can get the current node right?

    Node

     

     

    currentPage = Node.GetCurrent();

     and i can even loop through a nodes children,

     

    foreach (Node page incurrentPage.Children )

    {

    }

    but how do I find a nodes ancestor at a specific level?

  • Rodion Novoselov 694 posts 859 karma points
    Nov 18, 2011 @ 07:01
    Rodion Novoselov
    0

    Hi. Perhaps something like this would work:


    var childLevel = 42;

    var node = Node.GetCurrent();

    var xpath = string.Format("//*[@isDoc][@id = {0}]//*[@isDoc][@level = {1}]",
    node.Id,
    node.Level + childLevel);

    var nodes = library.GetXmlNodeByXPath(xpath).Cast<IHasXmlNode>()
    .Select(hasXmlNode => new Node(hasXmlNode.GetNode()));

Please Sign in or register to post replies

Write your reply to:

Draft