Skip to content
Fetch data from HTML and XML via xpath/css and prepare it with regexp
PHP HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea Run php-cs fixer only for main php version Jun 19, 2019
doc fix docs Jun 19, 2018
src clear documentation May 21, 2019
tests update test for load empty string May 21, 2019
.gitattributes
.gitignore Add idea configuration Mar 22, 2017
.php_cs_config.php #89 reorder methods Nov 2, 2017
.scrutinizer.yml
.travis.yml Run php-cs fixer only for main php version Jun 19, 2019
CHANGELOG.md update CHANGELOG.md May 22, 2019
CONTRIBUTING.md fixed: #7 Refactor Helper Dec 3, 2015
LICENSE.md change authors email Jun 20, 2019
README.md fix docs Jun 19, 2018
composer.json change authors email Jun 20, 2019
composer.lock build(deps-dev): bump phpunit/phpunit from 7.5.15 to 7.5.16 Sep 16, 2019
docker-compose.yml Add docker: development mode Jun 20, 2019
phpunit.xml.dist

README.md

ElementFinder

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Extract data from html with elegant xpath/css expressions and prepare data with regexp in single line.

Install

Via Composer

$ composer require xparse/element-finder

Usage

  $page = new ElementFinder($html);
  $title = $page->value('//title')->first();  
  echo $title;  

Advanced usage with regexp

$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
  */
  

Css selectors

Read this document. Using css selectors.

Testing

  ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

Xpath info

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.