2017 © Pedro Peláez
 

library dom-query

DOMQuery is a PHP library that allows to easily traverse and modify the DOM

image

artack/dom-query

DOMQuery is a PHP library that allows to easily traverse and modify the DOM

  • Thursday, February 6, 2014
  • by dmaletta
  • Repository
  • 2 Watchers
  • 8 Stars
  • 3,178 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

ATTENTION: This repository is archived and therefore readonly., (*1)

DOMQuery

DOMQuery is a PHP library that allows to easily traverse and modify the DOM, (*2)

Installation

Add in your composer.json:, (*3)

{
 "require": {
     "artack/dom-query": "*"
 }
}

Running the command:, (*4)

``` bash $ php composer.phar update artack/dom-query, (*5)


Usage ------- ### Tree Traversal ``` php $q = DOMQuery::create('

Title

  • first
  • second
  • last
' ); //output: 2 $q->getChildren()->count() //output: 3 $q->find('li')->count() //output: <li class="first">first</li> $q->find('li')->getFirst()->getHtml() //output: <li class="last">last</li> $q->find('li')->getLast()->getHtml() //output: <li class="second">second</li> $q->find('li')->filter('.second')->getHtml() //output: <li class="second">second</li> $q->find('li')->get(1)->getHtml() //output: ul $q->find('li')->getParent()->getName()

DOM Manipulation

``` php, (*6)

//output:, (*7)

Title

Text

DOMQuery::create(', (*8)

Title

') ->append('Text') ->getHtml(), (*9)

//output:, (*10)

Text

Title

DOMQuery::create(', (*11)

Title

') ->prepend('Text') ->getHtml(), (*12)

//output:, (*13)

Title H2

DOMQuery::create(', (*14)

Title

') ->find('h1') ->replace(', (*15)

Title H2

') ->getParent() ->getHtml(), (*16)

//output:, (*17)

New Title

DOMQuery::create(', (*18)

Title

') ->find('h1') ->replaceInner('New Title') ->getParent() ->getHtml(), (*19)

### Attribute Manipulation
``` php

//output: <img src="image.jpg" style="width:12px;" class="image">
DOMQuery::create('<img>')
    ->setAttribute('src', 'image.jpg')
    ->setStyle('width', '12px')
    ->addClass('image')
->getHtml()

HTML Output

``` php //output:, (*20)

Title

DOMQuery::create(', (*21)

Title

')->getHtml(), (*22)

//output: Title DOMQuery::create(', (*23)

Title

')->getInnerHtml() ```, (*24)

The Versions

06/02 2014

dev-master

9999999-dev

DOMQuery is a PHP library that allows to easily traverse and modify the DOM

  Sources   Download

The Requires

 

by David Maletta

dom traverse modify

06/02 2014

dev-develop

dev-develop

DOMQuery is a PHP library that allows to easily traverse and modify the DOM

  Sources   Download

The Requires

 

by David Maletta

dom traverse modify

06/02 2014

0.1.0

0.1.0.0

DOMQuery is a PHP library that allows to easily traverse and modify the DOM

  Sources   Download

The Requires

 

by David Maletta

dom traverse modify