2017 © Pedro Peláez
 

library php-xpath

PHP XPath Utilities

image

hugsbrugs/php-xpath

PHP XPath Utilities

  • Tuesday, March 28, 2017
  • by hugsbrugs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 131 Installations
  • HTML
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 12 % Grown

The README.md

php-xpath

This librairy provides utilities function to ease xpath manipulation, (*1)

Build Status Coverage Status, (*2)

Install

Install package with composer, (*3)

composer require hugsbrugs/php-xpath

In your PHP code, load librairy, (*4)

require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Xpath\Xpath as Xpath;

Usage

Extracts all elements matching query, (*5)

Xpath::extract_all($html, $query = '//a');

Extracts first element matching query, (*6)

Xpath::extract_first($html, $query = '//body//h3');

Extracts body of HTML document, (*7)

Xpath::get_body($html);

Replaces body of HTML document, (*8)

Xpath::replace_body($html, $new_body = '<div>Hello World !</div>');

XPath fails at extracting html tags style attributes content so this function makes it !, (*9)

Xpath::extract_style($html, $query = '//body//div[@class="inscriptionadsl"]', $style_property = 'height');

Extract first iframe from a webpage matching a given domain name, (*10)

Xpath::extract_iframe($html, $domain = 'hugo.maugey.fr');

Unit Tests

phpunit --bootstrap vendor/autoload.php tests

Author

Hugo Maugey visit my website ;), (*11)

The Versions

28/03 2017

dev-master

9999999-dev

PHP XPath Utilities

  Sources   Download

The Requires

 

The Development Requires