PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Michael A. Peters   docType   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Sample script
Class: docType
Create HTML or XHTML depending on the user browser
Author: By
Last change:
Date: 15 years ago
Size: 710 bytes
 

Contents

Class file image Download
<?php
require_once('xml_doctype.inc');
$dom = new DOMDocument('1.0','UTF-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;

$myPage = new docType($dom);
$xmlHtml = $myPage->document();

$xmlHead = $dom->createElement('head');
$xmlTitle = $dom->createElement('title','I Am a Web Page');
$xmlHead->appendChild($xmlTitle);
$xmlHtml->appendChild($xmlHead);

$xmlfile = 'content.xml';
$buffer = file_get_contents($xmlfile);
$tmpDOM = new DOMDocument('1.0','utf-8');
$tmpDOM->loadXML($buffer);
$nodeList = $tmpDOM->getElementsByTagName('body');
$impBody = $nodeList->item(0);
$xmlBody = $dom->importNode($impBody,true);
$xmlHtml->appendChild($xmlBody);

$myPage->sendheader();
$myPage->sendpage();
?>