Location: PHPKode > scripts > HTML and XML builder > example1.php
<?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;
		 
?>
Return current item: HTML and XML builder