Download the PHP package softcreatr/html5-dom-document-php without Composer
On this page you can find all versions of the php package softcreatr/html5-dom-document-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download softcreatr/html5-dom-document-php
More information about softcreatr/html5-dom-document-php
Files in softcreatr/html5-dom-document-php
Package html5-dom-document-php
Short Description HTML5 DOMDocument PHP library (extends DOMDocument)
License MIT
Homepage https://1-2.dev
Informations about the package html5-dom-document-php
HTML5DOMDocument
HTML5DOMDocument extends the native DOMDocument class in PHP. It fixes some long-standing issues and introduces additional, modern functionality for handling HTML5 documents.
Why Use HTML5DOMDocument?
- Preserves HTML entities that the native DOMDocument does not handle properly.
- Preserves void tags like
<input>
or<br>
, which DOMDocument tends to mishandle. - Allows inserting HTML code correctly into the document, ensuring that head and body elements are placed in their respective sections.
- Enables CSS-style selectors for querying the DOM:
- Supported selectors include
*
,tagname
,tagname#id
,#id
,tagname.classname
,.classname
, multiple class selectors, attribute selectors, and complex selectors likediv p
,div > p
,div + p
,p ~ ul
, anddiv, p
.
- Supported selectors include
- Element manipulation with:
element->classList
for manipulating classeselement->innerHTML
for working with the contents of an elementelement->outerHTML
for manipulating an entire element as a string
- Efficient handling of duplicate elements and IDs with advanced HTML insertion and validation.
Installation via Composer
Install via Composer with the following command:
Features & Improvements
- ClassList Support: The library adds support for manipulating classes of elements through the
classList
property, making it easier to work with CSS class attributes. - Enhanced Query Selectors: Use advanced CSS-like selectors for querying elements from the DOM, such as:
div > p
(direct child)div + p
(adjacent sibling)p ~ ul
(general sibling)[attribute]
,[attribute=value]
, etc.
- HTML Insertion: It allows inserting fragments of HTML into the document, intelligently placing them in the correct location (e.g., scripts into
<head>
, content into<body>
). - Custom Insert Targets: Define custom targets within the document for precise HTML insertion.
Documentation
Comprehensive documentation is available in the repository.
Examples
Basic Usage
Use HTML5DOMDocument just like the native DOMDocument:
Querying with CSS Selectors
Inserting HTML Code
Manipulating Class Attribute
Custom Insert Targets
License
This project is licensed under the MIT License. See the license file for more details.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to improve this library. Let's collaborate to make it even better.
Authors
- Original library by Ivo Petkov.
- V3 and ongoing maintenance by Sascha Greuel.
All versions of html5-dom-document-php with dependencies
ext-dom Version *
ext-libxml Version *