oscarotero / html-parser

Simple utility to parse html strings to DOMDocument

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTML parser

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

About

Simple utility to parse html strings to DOMDocument

License:MIT License


Languages

Language:HTML 98.7%Language:PHP 1.3%