Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tiago Wust Freres  >  SimpleHTMLElement  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example PHP doc
Class: SimpleHTMLElement
Create HTML and XML documents
Author: By
Last change:
Date: 2009-03-24 09:21
Size: 1,159 bytes
 

Contents

Class file image Download
<?php
/**
 * You can test this example with the not-indented class, by removing the comments from 
 * "include('htmlElement.inc')", and commenting "include('indent/htmlElement.inc')" to 
 * avoid conflicts.
 */

#include('htmlElement.inc');
include('indented/htmlElement.inc'); //indented class

/**
 * HTML example
 */
$div = new HTMLElement('div');
$div->appendText('TextNode test');
$div->setAttribute('id','divid1');
$div->setAttribute('name','divname1');

$div2 = new HTMLElement('div');
$div2->setAttribute('id','divid2');
$div2->setAttribute('name','divname2');

$div3 = new HTMLElement('div');
$div3->setAttribute('id','divid3');
$div3->setAttribute('name','divname3');

$div->appendChild($div2);
$div2->appendChild($div3);

#print_r($div);

echo $div->toHTML();


echo 
"\n\n"
/**
 * XML example
 */

$div = new HTMLElement('xml-doc');


$div2 = new HTMLElement('div');
$div2->setAttribute('id','divid2');
$div2->setAttribute('name','divname2');

$div3 = new HTMLElement('div');
$div3->setAttribute('id','divid3');
$div3->setAttribute('name','divname3');

$div->appendChild($div2);
$div->appendChild($div3);

#print_r($div);

echo $div->toXML();

?>