1. Go to this page and download the library: Download f4n70m/html-dom-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/ */
f4n70m / html-dom-parser example snippets
use HtmlDomParser\Parser;
$html = '<div>Привет, <a href="https://example.com">мир</a>!</div>';
$parser = new Parser($html);
$document = $parser->parse();
$element = $document->getChildren()->get(0);
echo $element->getLabel(); // "Привет, мир!"
// Информация о форматировании сохранена во фрагментах
foreach ($element->getFragments() as $fragment) {
echo $fragment->getType() . ': ' . $fragment->getStart() . '-' . $fragment->getEnd();
}
// a: 7-10