oscarotero/html-parser

Parse html strings to DOMDocument

Installs: 123 350

Dependents: 1

Suggesters: 0

Security: 0

Stars: 8

Watchers: 1

Forks: 2

Open Issues: 0

Language:HTML

v0.1.6 2020-11-19 17:43 UTC

This package is auto-updated.

Last update: 2021-11-19 19:37:45 UTC


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