main banner

Content Management

Escaping Field name in Sitecore Query

This time, I want for current post to summarize some field name escaping recommendations for Sitecore Query.

In a recent post I mentioned how an odd issue was crashing Sitecore Query because of a dash character contained in the name of an item. The bug was fixed escaping the item name with the ‘#’ char. This time, I want for current post to summarize some field name escaping recommendations for Sitecore Query.

Must be enclosed when Item name...

Example

contains dashes in name (“-”)

/sitecore/content/#Contact-Us#]

contains “and” or “or” word and is used before ‘//*’ symbols

/sitecore/content/Home/#News and Events#]//*

Starts with digits

/sitecore/content/Home/News/#2013#/January


Other remarkable considerations you need to make using item name in Sitecore Query:

  • Item names in the path expression are not case sensitive, the same result will be returned if you use the name upper or lower cased.
  • You can use escaped double quotes instead single quote with the same results

/sitecore/content//*[@Name=’Products’]

is equal to

/sitecore/content//*[@Name=\”Products\”]

  • Escaped double quotes become relevant to fix names which include single quote

/sitecore/content//*[@Description=\”Sitecore’s favorite topics\”]


Luis G.

An expert we all come to when in doubt, Luis was born in Monterrey and has a B.S. Electronic Systems Engineering degree His multiple abilities are backed 10 years of experience in .NET, SQL and recently joined the ranks of front end developers. A Star Wars and Lego enthusiast, he is also a loving father and a very friendly co-worker who writes for the Inflection Point’s blog with lots of inspiration and fills our blog with descriptions of our work environment that recall us all of the good times.

Articles