PHP code example of kevintweber / html-tokenizer
1. Go to this page and download the library: Download kevintweber/html-tokenizer 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/ */
kevintweber / html-tokenizer example snippets
php
namespace Kevintweber\HtmlTokenizer;
$htmlDocument = file_get_contents("path/to/html/document.html");
$htmlTokenizer = new HtmlTokenizer();
$tokens = $htmlTokenizer->parse($htmlDocument); // That was easy ...
// Once you have tokens, you can manipulate them.
foreach ($tokens as $token) {
if ($token->isElement()) {
echo $token->getName() . "\n";
}
}
// Or just output them to an array.
$tokenArray = $tokens->toArray();
echo "PHP code goes in here.";