Reputation: 2661
I have the following Sitecore queries:
Of specific note is I'm using the descendant axes feature of the Sitecore Query language (//), with /sitecore/content/Home/Clubs being my context.
I have my content structured as such:
When I run queries 1 and 2 in XPath Builder, I get content items 1 and 2; respectively. This is what I expect. However, when I run those same queries through Sitecore's API, I get a content not found error.
The following queries will work with Sitecore's API, mind you:
* /sitecore/content/home/clubs/*/17th
* /sitecore/content/home/clubs/*/*/20th
What I'm trying to accomplish is one query where I can get both children AND grandchildren of a content item with a specific name; a query like this:
/sitecore/content/Home/Clubs//{contentItemName}
I know I could just try
/sitecore/content/Home/Clubs/*/{contentItemName}
and fallback to
/sitecore/content/Home/Clubs/*/*/{contentItemName}
if that doesn't work, but that seems like a hack.
Is there anyway I can get the query I verified in the XPath builder works to work with the Sitecore API?
Upvotes: 1
Views: 1654
Reputation: 11442
I think you need the following in XPath builder:
/sitecore/content/Home/Clubs//*[@@name='20th']
or in the API:
/sitecore/content/Home/Clubs//*[@@name='{contentItemName}']
Upvotes: 1