2017 © Pedro Peláez
 

library html5-dom-document-php

HTML5 DOMDocument PHP library (extends DOMDocument)

image

ivopetkov/html5-dom-document-php

HTML5 DOMDocument PHP library (extends DOMDocument)

  • Friday, July 13, 2018
  • by ivopetkov
  • Repository
  • 9 Watchers
  • 60 Stars
  • 31,060 Installations
  • PHP
  • 14 Dependents
  • 0 Suggesters
  • 13 Forks
  • 4 Open issues
  • 41 Versions
  • 31 % Grown

The README.md

HTML5DOMDocument

HTML5DOMDocument extends the native DOMDocument library. It fixes some bugs and adds some new functionality., (*1)

Latest Stable Version License, (*2)

Why use?

  • Preserves html entities (DOMDocument does not)
  • Preserves void tags (DOMDocument does not)
  • Allows inserting HTML code that moves the correct parts to their proper places (head elements are inserted in the head, body elements in the body)
  • Allows querying the DOM with CSS selectors (currently available: *, tagname, tagname#id, #id, tagname.classname, .classname, tagname.classname.classname2, .classname.classname2, tagname[attribute-selector], [attribute-selector], "div, p", div p, div > p, div + p and p ~ ul.)
  • Adds support for element->classList.
  • Adds support for element->innerHTML.
  • Adds support for element->outerHTML.

Install via Composer

composer require "ivopetkov/html5-dom-document-php:2.*"

Documentation

Full documentation is available as part of this repository., (*3)

Examples

Use just like you should use DOMDocument:, (*4)

<?php
require 'vendor/autoload.php';

$dom = new IvoPetkov\HTML5DOMDocument();
$dom->loadHTML('<!DOCTYPE html><html><body>Hello</body></html>');
echo $dom->saveHTML();

Query the document with CSS selectors and get the innerHTML and the outerHTML of the elements:, (*5)

$dom = new IvoPetkov\HTML5DOMDocument();
$dom->loadHTML('<!DOCTYPE html><html><body>

Hello

This is some text
</body></html>'); echo $dom->querySelector('h1')->innerHTML; // Hello echo $dom->querySelector('.content')->outerHTML; //
This is some text

Insert HTML code into a HTML document (other HTML code):, (*6)

$dom = new IvoPetkov\HTML5DOMDocument();
$dom->loadHTML('
    <!DOCTYPE html>
    <html>
        <head>
            <style>...</style>
        </head>
        <body>
            <h1>Hello</h1>
        </body>
    </html>
');

$dom->insertHTML('
    <html>
        <head>
            <script>...</script>
        </head>
        <body>
            <div>This is some text</div>
        </body>
    </html>
');

echo $dom->saveHTML();
// <!DOCTYPE html>
//     <html>
//         <head>
//             <style>...</style>
//             
//         </head>
//         <body>
//             

Hello

//
This is some text
// </body> // </html>

Manipulate the values of the class attribute of an element:, (*7)

$dom = new IvoPetkov\HTML5DOMDocument();
$dom->loadHTML('

'); echo $dom->querySelector('div')->classList->add('class2');

License

This project is licensed under the MIT License. See the license file for more information., (*8)

Contributing

Feel free to open new issues and contribute to the project. Let's make it awesome and let's do in a positive way., (*9)

Authors

This library is created and maintained by Ivo Petkov (ivopetkov.com) and some awesome folks., (*10)

The Versions

13/07 2018

dev-master

9999999-dev

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-dom *

 

The Development Requires

13/07 2018

v0.6.1

0.6.1.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-dom *

 

The Development Requires

21/06 2018

v0.6.0

0.6.0.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-dom *

 

The Development Requires

21/06 2018

v0.5.10

0.5.10.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-dom *

 

The Development Requires

28/04 2018

v0.5.9

0.5.9.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

19/12 2017

v0.5.8

0.5.8.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

08/12 2017

v0.5.7

0.5.7.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

25/08 2017

v0.5.6

0.5.6.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

03/08 2017

v0.5.5

0.5.5.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

02/08 2017

v0.5.4

0.5.4.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

02/08 2017

v0.5.3

0.5.3.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

31/07 2017

v0.5.2

0.5.2.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

25/07 2017

v0.5.1

0.5.1.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

25/07 2017

v0.5.0

0.5.0.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/07 2017

v0.4.16

0.4.16.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

14/06 2017

v0.4.15

0.4.15.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

13/06 2017

v0.4.14

0.4.14.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

08/06 2017

v0.4.13

0.4.13.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/06 2017

v0.4.12

0.4.12.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/06 2017

v0.4.11

0.4.11.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/06 2017

v0.4.10

0.4.10.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/06 2017

v0.4.9

0.4.9.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

30/05 2017

v0.4.8

0.4.8.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

19/05 2017

v0.4.7

0.4.7.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

08/03 2017

v0.4.6

0.4.6.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

21/02 2017

v0.4.5

0.4.5.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

31/01 2017

v0.4.4

0.4.4.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

23/01 2017

v0.4.3

0.4.3.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

09/01 2017

v0.4.2

0.4.2.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/10 2016

v0.4.1

0.4.1.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

07/10 2016

v0.4.0

0.4.0.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

29/08 2016

v0.3.5

0.3.5.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

29/08 2016

v0.3.4

0.3.4.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

21/08 2016

v0.3.3

0.3.3.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

21/08 2016

v0.3.2

0.3.2.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

03/07 2016

v0.3.1

0.3.1.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

03/06 2016

v0.3.0

0.3.0.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

13/04 2016

v0.2.2

0.2.2.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

13/04 2016

v0.2.1

0.2.1.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

31/03 2016

v0.2

0.2.0.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

30/03 2016

v0.1

0.1.0.0

HTML5 DOMDocument PHP library (extends DOMDocument)

  Sources   Download

MIT

The Requires

  • php >=5.5.0