oscarotero/html-parser
Fast, lightweight HTML parser for PHP by Oscar Otero. Parse HTML into a DOM-like structure, query and traverse nodes, extract text/attributes, and handle real-world, imperfect markup. Useful for scraping, content cleanup, and transformations.
Simple utility to parse html strings to 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);
How can I help you explore Laravel packages today?