oscarotero/html-parser
将HTML字符串解析为DOMDocument
v0.1.8
2023-11-29 20:28 UTC
Requires
- php: ^7.2 || ^8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.11
- phpunit/phpunit: ^8.0
README
一个简单的工具,可以将HTML字符串解析为DOMDocument。
composer require oscarotero/html-parser
用法
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);