PHP Classes

DOM HTML Element: Manipulate HTML page elements using DOM Document

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 343 All time: 7,058 This week: 455Up
Version License PHP version Categories
dom-html-element 1.0GNU General Publi...5.0HTML, PHP 5
Description 

Author

This class can manipulate HTML page elements using DOM Document.

It extends the DOMDocument class to wrap an HTML page element of a given type.

The class provides means to compose HTML document elements by providing the same functions as the DOMElement class including appending child elements also of this class.

The HTML code of the resulting document excerpt can be returned as a single string.

Picture of Everton da Rosa
  Performance   Level  
Name: Everton da Rosa <contact>
Classes: 17 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 3x

Example

<html>
    <head>
        <title>HTMLElement test</title>
    </head>
    <body>
        <?php

       
require_once 'htmlelement.class.php';

       
$div = new HTMLElement('div');//create a main HTMLElement
       
$p = new HTMLElement('p');//create other HTMLElement
       
$p->appendChild(new DOMText('Test'));//append text to HTMLElement
       
$p->setAttribute('style', 'color: green');
       
$div->appendChild($p);//append child to main HTMLElement
       
$div->appendChild(new DOMElement('p', 'It\'s Work!'));//append a DOMElement to main HTMLElement
       
$div->setAttribute('style', 'color: red');
       
$code = $div->getCode();//get HTML code
       
echo $code;//show HTMLElement
       
highlight_string($code);//show source-code

       
?>
</body>
</html>


  Files folder image Files (2)  
File Role Description
Plain text file htmlelement.class.php Class Main class file
Accessible without login Plain text file index.php Example Example of use

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:343
This week:0
All time:7,058
This week:455Up