The below query fails and throws exception. /sitecore/content/Abcdef/Sites/WXYZ/MNO/Application Contexts/Connect On Demand/Sections/Self Service/* returns "::" expected at position 92.

where as I am getting results if the query /sitecore/content/Abcdef/Sites/WXYZ/MNO/Application Contexts/Connect On Demand/Sections/*

4 Answers 4


The problem

You are running into one of many inherent problems with using Sitecore Query. The problem is; self is a reserved word - and therefore /Self Service/ fails.


Now in this instance you can (probably) work around it using some of the suggestions already given. Escape the query like .../#Self Service#/ - but this will only work if you plan to be using a static query where you know the full path in advance.

A way around this limitation would be to reconstruct the query like this:

/sitecore/content/*[@'name='Abcdef']/*[@@name='Sites']/etc etc etc/*[@@name='Self Service']/*

But it's not pretty.

Alternative Solution

Or in the case of your example query, replace the Sitecore Query call entirely, with a call to .GetItem("/sitecore/content/Abcdef/Sites/WXYZ/MNO/Application Contexts/Connect On Demand/Sections/Self Service") and .GetChildren().


Reserved words in Sitecore Query:

  • ancestor
  • and
  • child
  • descendant
  • div
  • false
  • following
  • mod
  • or
  • parent
  • preceding
  • self
  • true
  • xor


  • If this really is a reserved word issue, as it certainly looks to be, I suggest raising this as a bug with Sitecore. The query parser should certainly not be returning this error for a query with self in it. Either way, escaping is needed where the path contains a space. Rewriting the query different ways doesn't solve the issue of knowing the path in advance though. You could just form the query string on the fly of course. Commented Dec 26, 2016 at 21:37

Can you try this

/sitecore/content/Abcdef/Sites/WXYZ/MNO/Application Contexts/Connect On Demand/Sections/#Self Service#/*

Which handles escape sequence i.e. space in itemname

  • Hi Balaji, I am querying this from the code behind. When i am trying this from the xpath builder by selecting Sitecore Query Notation I am seeing the same error though.
    – Meghan
    Commented Dec 26, 2016 at 7:37

Each item that takes part in a query path and has a space(s) should be wrapped in ##.

/sitecore/content/Abcdef/Sites/WXYZ/MNO/#Application Contexts#/#Connect On Demand#/Sections/#Self Service#/*

I was able to resolve this issue and identify a workaournd. I was using the Sitecore.Configuration.Factory.GetDatabase("master").SelectItems(query) This doesnt work if we have Sitecore reserved words. In my case I need only one item and I changed my code to use Sitecore.Configuration.Factory.GetDatabase("master").GetItem() and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.