Переводчик
класс Переводчик реализует Интерфейс переводчика
Интерфейс переводчика выражений XPath.
Этот компонент является портированной версией Python библиотеки cssselect, авторские права принадлежат Ian Bicking, см. https://github.com/SimonSapin/cssselect.
Методы
| __construct(Интерфейс парсера $parser = null) Конструктор. | ||
| статический string | getXpathLiteral(string $element) | |
| string | cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::') Переводит CSS селектор в выражение XPath. | |
| string | selectorToXPath(Узел селектора $selector, string $prefix = 'descendant-or-self::') Переводит обработанный узел селектора в выражение XPath. | |
| Переводчик | registerExtension(Интерфейс расширения $extension) Регистрирует расширение. | |
| Интерфейс расширения | getExtension(string $name) | |
| Переводчик | registerParserShortcut(Интерфейс парсера $shortcut) Регистрирует сокращённый парсер. | |
| XPathExpr | nodeToXPath(Интерфейс узла $node) | |
| XPathExpr | addCombination(string $combiner, Интерфейс узла $xpath, Интерфейс узла $combinedXpath) | |
| XPathExpr | addFunction(XPathExpr $xpath, Узел функции $function) | |
| XPathExpr | addPseudoClass(XPathExpr $xpath, string $pseudoClass) | |
| XPathExpr | addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, string $value) |
Подробности
__construct(ParserInterface $parser = null)
Конструктор.
Параметры
| ParserInterface | $parser |
static string getXpathLiteral(string $element)
Параметры
| string | $element |
Значение возврата
| string |
string cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::')
Преобразует CSS-селектор в выражение XPath.
Параметры
| string | $cssExpr | |
| string | $prefix |
Значение возврата
| string |
string selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::')
Преобразует узел обработанного селектора в выражение XPath.
Параметры
| SelectorNode | $selector | |
| string | $prefix |
Значение возврата
| string |
Translator registerExtension(ExtensionInterface $extension)
Регистрирует расширение.
Параметры
| ExtensionInterface | $extension |
Значение возврата
| Translator |
ExtensionInterface getExtension(string $name)
Параметры
| string | $name |
Значение возврата
| ExtensionInterface |
Исключения
| ExpressionErrorException |
Translator registerParserShortcut(ParserInterface $shortcut)
Регистрирует сокращенный парсер.
Параметры
| ParserInterface | $shortcut |
Значение возврата
| Translator |
XPathExpr nodeToXPath(NodeInterface $node)
Параметры
| NodeInterface | $node |
Значение возврата
| XPathExpr |
Исключения
| ExpressionErrorException |
XPathExpr addCombination(string $combiner, NodeInterface $xpath, NodeInterface $combinedXpath)
Параметры
| string | $combiner | |
| NodeInterface | $xpath | |
| NodeInterface | $combinedXpath |
Значение возврата
| XPathExpr |
Исключения
| ExpressionErrorException |
XPathExpr addFunction(XPathExpr $xpath, FunctionNode $function)
Параметры
| XPathExpr | $xpath | |
| FunctionNode | $function |
Значение возврата
| XPathExpr |
Исключения
| ExpressionErrorException |
XPathExpr addPseudoClass(XPathExpr $xpath, string $pseudoClass)
Параметры
| XPathExpr | $xpath | |
| string | $pseudoClass |
Значение возврата
| XPathExpr |
Исключения
| ExpressionErrorException |
XPathExpr addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, string $value)
Параметры
| XPathExpr | $xpath | |
| string | $operator | |
| string | $attribute | |
| string | $value |
Значение возврата
| XPathExpr |
Исключения
| ExpressionErrorException |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/CssSelector/XPath/Translator.html