protected function _css_toxpath_selector($css_selector) {
		$xpath = $css_selector;

		// if there was passed a xpath expression
		if (strpos($xpath, 'xpath:') !== false) return substr($xpath, 6);

		// child elements
		$xpath = preg_replace('/([a-z0-9_-])\s+([a-z0-9_-])/', '$1//$2', $xpath);

		// direct child elements ( > )
		$xpath = preg_replace('/\s*>\s*/', '/', $xpath);

		// element with attribute
		$xpath = preg_replace('/\[([^\]]+)\]/', '[@$1]', $xpath);

		// element with starts-with selector
		$xpath = preg_replace('/\[@(.+)\^=(.+)\]/i', '[starts-with(@$1, $2)]', $xpath);

		// element with contains selector
		$xpath = preg_replace('/\[@(.+)\*=(.+)\]/i', '[contains(@$1, $2)]', $xpath);

		// element by id
		$xpath = preg_replace('/#([a-z0-9_-]+)/', '*[@id="$1"]', $xpath);

		// elements by class
		$xpath = preg_replace('/\.([a-z0-9_-]+)/', '*[contains(concat(" ", @class, " ")," $1 ")]', $xpath);

		// cleanup such elements div*
		$xpath = preg_replace('/([a-z0-9_-]+)\*/', '$1', $xpath);

		// first-child
		$xpath = preg_replace('/:first-child/', '[1]', $xpath);

		// nth-child
		$xpath = preg_replace('/:nth-child\((\d+)\)/', '[$1]', $xpath);

		// following elements ( + )
		$xpath = preg_replace('/\s*\+\s*/', '/following-sibling::*[1]/self::', $xpath);

		return '//' . $xpath;
	}