[2.0][Component][DomCrawler] cs

This commit is contained in:
Włodzimierz Gajda 2012-04-23 19:19:47 +02:00
parent 44ba841a67
commit 25fed1355b

View File

@ -621,6 +621,28 @@ class Crawler extends \SplObjectStorage
return $form;
}
/**
* Converts string for XPath expressions.
*
* Escaped characters are: quotes (") and apostrophe (').
*
* Examples:
* <code>
* echo Crawler::xpathLiteral('foo " bar');
* //prints 'foo " bar'
*
* echo Crawler::xpathLiteral("foo ' bar");
* //prints "foo ' bar"
*
* echo Crawler::xpathLiteral('a\'b"c');
* //prints concat('a', "'", 'b"c')
* </code>
*
* @param string $s String to be escaped
*
* @return string Converted string
*
*/
static public function xpathLiteral($s)
{
if (false === strpos($s, "'")) {