trejeraos/dom-selector

This package makes selecting XML elements easy by using CSS like selectors

v1.0.1 2016-02-12 00:27 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:36:56 UTC


README

DOMSelector makes selecting HTML/XML elements easy by using CSS like selectors.

Usage

<?php
use trejeraos\DOMSelector;

$html = <<<'HTML'
<!DOCTYPE html>
<html>
    <body>
        <p class="message">Hello World!</p>
        <P>Hello DOMSelector!</P>
    </body>
</html>
HTML;

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

$dom = new DOMSelector($doc);

echo $dom->querySelector('.message')->nodeValue;

Limitations

See: Limitations of the CssSelector Component