Copied to clipboard

Flag this post as spam?

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


  • Keyur Shah 14 posts 44 karma points
    Oct 10, 2014 @ 07:54
    Keyur Shah
    0

    Search using XPath in UmbracoContext.Current.ContentCache.GetByXPath(xpath)

    Hi,

    on click of save and publish event(on saving not on saved) I would like to do searching using xpath in UmbracoContext.Current.ContentCache.GetByXPath(xpath).

    what I would like to do is I want siblings  of the current node excluding current node.

    solution 1:

    var currentNode = new Node(args.SavedEntities.FirstOrDefault().Id); //hasIdentity
                   var siblings = currentNode.GetSiblingNodes();

    Solution 2:

    using xpath

    var xpath = "preceding-sibling::*[@isDoc and normalize-space(umbracoUrlName)]" ; // and Following siblings 
    var umbracoUrlNameList = UmbracoContext
                    .Current
                    .ContentCache.GetByXPath(xpath)
                    .OrderByDescending(x => x.Level)
                    .Select(x => x.GetPropertyValue<string>("umbracoUrlName"));
    
    I am not sure how to achieve 2nd solution any help  would be appreciated.
    specially how to write the xpath though I got basic understanding about xpath from link  here http://our.umbraco.org/wiki/reference/xslt/xpath-axes-and-their-shortcuts
    Thanks,
Please Sign in or register to post replies

Write your reply to:

Draft