oscarotero/html-parser

将HTML字符串解析为DOMDocument

安装数: 2,314,334

依赖: 1

建议: 0

安全: 0

星标: 15

关注者: 4

分支: 2

开放问题: 0

语言:HTML

v0.1.8 2023-11-29 20:28 UTC

This package is auto-updated.

Last update: 2024-08-29 22:05:56 UTC


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);