PHP code example of oscarotero / html-parser

1. Go to this page and download the library: Download oscarotero/html-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oscarotero / html-parser example snippets


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