Contentment Data Source XPath Checkbox List Attribute Value

I could really use some help with an XPath for my Contentment Data Source!

This XPath works for selecting all appliances children of the finishes node.
$site/finishes/appliances

I need to filter further to select all appliances that have the attribute productType = “XYZ”. Note: productType is a checkbox list so it’s an IEnumerable. I’ve tried all of the following, but have been unable to find the XPath that works.

  1. $site/finishes/appliances[@productType=‘XYZ’]
  2. $site/finishes/appliances[contains(concat(’ ', @productType, ’ '), ’ XYZ ')]
  3. $site/finishes/appliances[contains(concat(‘,’, @productType, ‘,’), ‘,XYZ,’)]
  4. $site/finishes/appliances[contains(concat(‘,’, translate(normalize-space(@productType), ‘abcdefghijklmnopqrstuvwxyz’, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’), ‘,’), ‘,XYZ,’)]

Anybody know the correct XPath?

Hi Ben :waving_hand:

I don’t know exactly how Umbraco content gets serialized to XML for use with XPath these days, but in the old days, properties were child elements of the document; only @nodeName and @template etc. were real XML attributes - so my guess is that if you take off the ‘@’ sign, most of your XPaths above will actually work; I’d start with this to see if you’re getting anywhere:

$site/finishes/appliances[contains(productType, 'XYZ')]

Hope that helps :slight_smile:

/Chriztian

@greystate Thank for the response. Unfortunately $site/finishes/appliances[contains(productType, ‘XYZ’)] did not do the trick.

Figured it out! Finally! I’m a bonehead! I had to go up one level in the Contentment settings.

I was using a “Umbraco Content” picker…which does allow for an XPath data source. But, that data source XPath is for picking a parent node.

I switched to an “Umbraco Content by XPath” picker…and now my XPath queries work like a charm.

1 Like