Extract data from html with elegant xpath/css expressions and prepare data with regexp in single line.
Via Composer
$ composer require xparse/element-finder
$page = new ElementFinder($html);
$title = $page->value('//title')->first();
echo $title;
$page = new \Xparse\ElementFinder\ElementFinder('<html>
<div class="tels">
044-12-12,
258-16-16
</div>
<div class="tels">
(148) 04-55-16
</div>
</html>');
$tels = $page->value('//*[@class="tels"]')->split('!,!')->replace("![^0-9]!");
print_r($tels);
/*
[0] => 0441212
[1] => 2581616
[2] => 148045516
*/
Read this document. Using css selectors.
./vendor/bin/phpunit
Please see CONTRIBUTING for details.
- XPath/CSS Equivalents
- Choose between XPath and jQuery with an XPath-jQuery phrase book
- XPath and CSS Selectors
The MIT License (MIT). Please see License File for more information.