1. Go to this page and download the library: Download manychois/simdom 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/ */
manychois / simdom example snippets
$parser = \Manychois\Simdom\Dom::createParser();
$doc = $parser->parseFromString('<p>Hello, world!</p>');
// $doc is an instance of \Manychois\Simdom\Document
// Standard DOM methods for traversal and manipulation are available
$html = $doc->documentElement();
$body = $html->children()->item($html->children()->length() - 1);
$body->append(\Manychois\Simdom\Dom::createElement('div'));
// Simdom also provides extra convenient methods like dfs (Depth First Search)
foreach ($doc->dfs() as $node) {
if ($node instanceof \Manychois\Simdom\Comment) {
echo $node->data() . "\n";
}
}
$option = new \Manychois\Simdom\PrettyPrintOption();
$option->indent ="\t";
echo \Manychois\Simdom\Dom::print($doc, $option);
$converter = new \Manychois\Simdom\DomNodeConverter();
$domDoc = new \DOMDocument();
// Convert DOMElement to Element and you can start playing with Simdom
$element = $converter->convertToElement($domDoc->createElement('html'));
// Convert Element back to DOMElement and you can import it to DOMDocument
$domElement = $converter->importElement($element, $domDoc);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.