phpgt/cssxpath

Convert CSS selectors to XPath queries.

Fund package maintenance!
PhpGt

Installs: 1 058 871

Dependents: 2

Suggesters: 0

Security: 0

Stars: 9

Watchers: 2

Forks: 8

Open Issues: 6

v1.1.4 2021-11-13 15:40 UTC

README

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");