Copied to clipboard

Flag this post as spam?

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


  • suzyb 474 posts 932 karma points
    Dec 18, 2012 @ 15:50
    suzyb
    0

    Select items where children have specific property

    From the following structure I want to select all the countries that have a property (essentialExperiences) set.  This property is an embedded content datatype which seems to set it to <data /> when nothing has been set for it.

    Main Page
    --- Continent
    ----- Country Listing
    --------- Country

    So far I select all the continents and loop through them.  In my loop I then have this to select 1 random country that has the essentialExperiences set.

    item.Descendants("CountryPage").Where("essentialExperiences!= \"<data />\"").Random(1);

    Nothing seems to be getting selected even though there is one country that has the essential experiences set.  Can anyone enlighten me where I'm wrong.

  • suzyb 474 posts 932 karma points
    Jan 15, 2013 @ 15:22
    suzyb
    0

    Guess no one knows then :/

  • Niels Jorck Ellegaard 39 posts 245 karma points
    Jan 22, 2013 @ 12:09
    Niels Jorck Ellegaard
    0

    Sorry for the late reply, hope your strill around :)

    Dont hang me on this one as I havent tested it.

    Embedded Content is a bit wierd in the way it works, but if I remember correctly you can access the date with the property name and .InnerText to get the value.

    So it ought to be something like this:

    item.Descendants("CountryPage").Where("!string.IsNullOrWhiteSpace(essentialExperiences.InnerText)").Random(1);

    If nothing else, it might give you some new ideas for testing :)

Please Sign in or register to post replies

Write your reply to:

Draft