Copied to clipboard

Flag this post as spam?

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


  • Delete me 45 posts 66 karma points
    Jun 03, 2010 @ 13:10
    Delete me
    0

    Search in Children

    Hi all

    In C# I want to do this:
    Find out if a node with "thisname" excists in doc1.Children or doc2.Children.

    Is there a better, and more resource-friendly way of doing this, than just two foreach loops?

     

    Thanks,
    Mathias

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jun 03, 2010 @ 14:36
    Matt Brailsford
    0

    If the nodes are published, you could use umbraco.library.GetXmlNodeById or umbraco.library.GetAll and just run an XPath statement?

    Matt

  • Jeff Grine 149 posts 189 karma points
    Jun 03, 2010 @ 14:39
    Jeff Grine
    0

    Or umbraco.library.GetXmlByXPath

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jun 03, 2010 @ 14:40
    Matt Brailsford
    0

    Or that =)

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jun 03, 2010 @ 14:43
    Lee Kelleher
    2

    You could try Hendy's Umbraco Helper class?

    http://blog.hendyracher.co.uk/umbraco-helper-class/

    There is a method for "GetChildNodeByName" ... or you can use XPath with one of the other methods? like "GetNodesFromXpath".

    Cheers, Lee.

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Jun 03, 2010 @ 14:51
    Matt Brailsford
    0

    Sweet. I really need to start following Hendys blog.

    Matt

  • Delete me 45 posts 66 karma points
    Jun 08, 2010 @ 10:01
    Delete me
    0

    Thanks all!

    I now use GetXmlByXPath to serach for the node excistence:

    XPathNodeIterator n = umbraco.library.GetXmlNodeByXPath("/root/node [@nodeName = 'Runway Homepage']/node [@nodeName = 'TheNode']");

    Now, what is the best way to see if the node excists or not, fx. a trye/false output?

    Thanks again,
    Mathias

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies