Tag: XPath

Clean your XPath

March 01, 2011
Tags: SDN, Sitecore, XPath

While developing with Sitecore you'll probably end up using XPath query to return some results. Since a lot of people will be requiring you to create content items with dashes in the name, for SEO purposes, you're going to need to escape the dashes with "#" (pound) signs as detailed in this SDN Sitecore Query Syntax article. This means you'll need a method to clean your XPath queries. Having done this a few times and integrated mine with other developers versions, here's what I've come up with: