Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of shrawan  >  HTML and XML builder  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: example
Class: HTML and XML builder
Compose HTML and XML documents programmatically
Author: By
Last change:
Date: 4 years ago
Size: 2,734 bytes
 

Contents

Class file image Download
<?php 
    
include('XHBuilder.php');


    
/*remember every opening tag must have a closing tag
     *closing a tag with close(), points to the previous tag 
     * */
   
    /*remove the comment to view as xml*/
    //header('Content-type:text/xml');
    
    
    
$html=new html('html');
    
$html->
           
head->title->text('HTML Example')->close()/*close titlr*/
           
->close();/*close head*/    

    
$html->body
         
->div->style('font-size:50px;')->text('I AM DIV')->close()/*close div*/
         
->div->id('formHolder')->close()/*close div*/ 
         
->div->class('formHolder')->close()/*close div*/ 
         
->div->title('titlename')->close();/*close div*/ 
         
    
$html->h1->id('h1')->style('color:red;')->text('I AM H1')->close();     
           
    
    
    
$form=new html('form');
    
$form->input->type('text')->style('font-family:arial;font-weight:10px')->id('example')->class('example')->close()
         ->
input->type('text')->style('font-family:arial;font-weight:10px')->id('example1')->class('example2')->close();
    
    
    
/*to check the example remove the comment one by one*/
    /* search for tag
     * find ([tagname])
     * 
     * */
    
    //$html->find('head')->insert($form);

    
    /* search for id
     * find (#[idName])
     * 
     * */
         
    //$html->find('#formHolder')->insert($form);
    
    
    /* search for class
     * find (.[className])
     * 
     * */
         
    //$html->find('.formHolder')->insert($form);
    
    
    /* search for any other attributes
     * find (&[attributeName])
     * 
     * */
         
    //$html->find('&title')->insert($form);
    
    
    
    /* 
     * search with attribute value
     * find('attributeName','attributeValue')
     * 
     */
         
    //$html->find('title','titlename')->insert($form);
    //$html->find('id','formHolder')->insert($form);
    //$html->find('class','formHolder')->insert($form);
         
         
    /*
     * insert(object,true or false(by default false))
     * 
     * true means insert the object befor the current tag gets closed
     */     
    
    //$html->find('body')->insert($form,true);
    
    /*
     * false (which is default) inserts just after the current tag
     */
    //$html->find('body')->insert($form);
    

         
    /*
     * if find doesn't find any matches it will point to the current tag
     * 
     */      
    
         
  
$html->find('h1')->text(null)/*clears the text for current tag*/         
                   
->text('I m new Text')/*again set the new text*/
                   
->style(null)/*deletes the attribute with name style*/
                   
->id(null)/*deletes the attribute with name id*/
                   
->id('newH1')/*again set the new attribute id*/
                   
->style('color:blue;'/*again set the color to blue for h1*/
                   
->clearAttribute('style')/*clear style attribute values*/
                   
->alterTag('H6')    /*chage the tag name h1 to h6*/
  
;
         
    echo 
$html;
         
?>