Sitecore Query Notation in X-Path Builder

2.3k Views Asked by At

I am having an issue with Sitecore's XPath Query utility in the developer centre, I have selected to use 'Sitecore Query Notation' over XPath as I want to return field values of items I am selecting. I cannot seem to get it to return field values like I want to (for example path, and price field on the items)

I am running the query below:

select @@path
from /sitecore/content/Product Repositories/*

And I get the following message:

End of string expected at position 6.

Does anyone know what might be causing this to not return results?

2

There are 2 best solutions below

4
On BEST ANSWER

The Syntax select @@path from can be used with Sitecore rocks query analyzer, but can't be used within Sitecore Developer center or by Sitecore query API.

So your query in developer center should be like:

/sitecore/content/Product Repositories/*

In code, you can retrieve items based on your query then fetch the fields you need

string query = "/sitecore/content/Product Repositories/*"; 
Item[] items = Sitecore.Context.Database.SelectItems(query);

foreach(Item item in items )
{
    var path = item.Paths.FullPath;
    ...

}
3
On

The space is the issue. It should read:

select @@path
from /sitecore/content/#Product Repositories#/*