oscarotero / html-parser
Parse html strings to DOMDocument
Installs: 2 713 852
Dependents: 1
Suggesters: 0
Security: 0
Stars: 15
Watchers: 4
Forks: 2
Open Issues: 0
Language:HTML
Requires
- php: ^7.2 || ^8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.11
- phpunit/phpunit: ^8.0
README
Simple utility to parse html strings to DOMDocument.
composer require oscarotero/html-parser
Usage
use HtmlParser\Parser; $html = '<html><head></head><body>Hello world</body></html>'; //Convert a string to a DOMDocument $document = Parser::parse($html); //Convert a string to a DOMDocumentFragment $fragment = Parser::parseFragment('<p>Hello world</p>'); //Convert a DOMDocument or DOMDocumentFragment to a string echo Parser::stringify($document); echo Parser::stringify($fragment);