PHP code example of vladshut / php-dom-wrapper

1. Go to this page and download the library: Download vladshut/php-dom-wrapper 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/ */

    

vladshut / php-dom-wrapper example snippets


{
  ""scotteh/php-dom-wrapper": "dev-master"
  }
}
 bash
curl -sS https://getcomposer.org/installer | php
 bash
php composer.phar install
 php
 php
use DOMWrap\Document;

$html = '<ul><li>First</li><li>Second</li><li>Third</li></ul>';

$doc = new Document();
$doc->html($html);
$nodes = $doc->find('li');

// Returns '3'
var_dump($nodes->count());

// Append as a child node to each <li>
$nodes->append('<b>!</b>');

// Returns: <html><body><ul><li>First<b>!</b></li><li>Second<b>!</b></li><li>Third<b>!</b></li></ul></body></html>
var_dump($doc->saveHTML($doc));