2017 © Pedro Peláez
 

library xpath

image

h0gar/xpath

  • Thursday, August 11, 2016
  • by leyou
  • Repository
  • 3 Watchers
  • 4 Stars
  • 1,217 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Xpath

Build Status, (*1)

A lightweight package for xpath manipulations., (*2)

, (*3)

Installation

composer require h0gar/xpath *

, (*4)

Usage

HTML, (*5)

$html = file_get_contents('page.html');
$doc = new \H0gar\Xpath\Doc($html, 'html');

XML, (*6)

$xml = file_get_contents('page.xml');
$doc = new \H0gar\Xpath\Doc($xml, 'xml');

, (*7)

Access a node

$item = $doc->item('/html/body/div[1]/div/div[2]/ul/li[0]');
#or
$item = $doc->item('/html/body/div[1]')->item('div/div[2]/ul/li', 1);

, (*8)

Access multiple nodes

$items = $doc->items('/html/body/div[1]/div/div[2]/ul/li');
foreach($items as $item)
    //...

, (*9)

$next = $item->next();
$prev = $item->prev();
$parent = $item->parent();

, (*10)

Get a node inner html

$html = $item->html();
#or
$html = $doc->html('/html/body/div[1]/div/div[2]/ul/li[0]');
#or
$html = $doc->html('/html/body/div[1]/div/div[2]/ul/li', 1);

, (*11)

Get a node inner text

$text = $item->text();
#or
$text = $doc->text('/html/body/div[1]/div/div[2]/ul/li[0]');
#or
$text = $doc->text('/html/body/div[1]/div/div[2]/ul/li', 1);

, (*12)

Get an attribute

$href = $item->attr('href');

, (*13)

\DOMElement and \DOMXpath

$domelement = $item->getNode();
$domxpath = $item->getXpath();

Contributing

Please submit all issues and pull requests to the h0gar/xpath repository., (*14)

License

Open-sourced software licensed under the MIT license, (*15)

The Versions

11/08 2016

dev-master

9999999-dev

  Sources   Download

MIT

by Michel Hognerud

04/01 2016

0.1.4

0.1.4.0

  Sources   Download

MIT

by Michel Hognerud

25/05 2015

0.1.3

0.1.3.0

  Sources   Download

MIT

by Michel Hognerud

15/09 2014

0.1.2

0.1.2.0

  Sources   Download

MIT

by Michel Hognerud

11/09 2014

v0.1.1

0.1.1.0

  Sources   Download

MIT

by Michel Hognerud

05/09 2014

v0.1.0

0.1.0.0

  Sources   Download

MIT

by Michel Hognerud