Files
FreshRSS/lib/phpgt/cssxpath
Alexandre Alapetite 2acf3a4dd8 CssXPath-StarSelector (#4506)
* CssXPath-StarSelector
Add support for selectors such as `a[href*="example"]`
https://developer.mozilla.org/docs/Web/CSS/Attribute_selectors
Translated to `.//a[contains(@href,"example")]`

Upstream PR: https://github.com/PhpGt/CssXPath/pull/181

* Upstream merged
2022-08-18 11:14:40 +02:00
..
2022-08-18 11:14:40 +02:00
2022-08-18 11:14:40 +02:00

Translate CSS selectors to XPath queries

A lightweight and dependency free CSS to XPath translator. This repository is used to bring modern DOM functionality like querySelectorAll() to PHP in the PHP.Gt/Dom project.


Build status Code quality Code coverage Current version PHP.Gt/CssXPath documentation

Example usage

use Gt\CssXPath\Translator;

$html = <<<HTML
<form>
	<label>
		Name
		<input name="name" />
	</label>
	<label>
		Code:
		<input name="code" />
	</label>
	<button name="do" value="submit">Submit code</button>
</form>
HTML;

$document = new DOMDocument();
$document->loadHTML($html);

$xpath = new DOMXPath($document);
$inputElementList = $xpath->query(new Translator("form>label>input");