PHP Classes

File: changelog.php

Recommend this page to a friend!
  Classes of troels knak-nielsen   xmllib   changelog.php   Download  
File: changelog.php
Role: Example script
Content type: text/plain
Description: demonstration
Class: xmllib
Parse XML documents without external libraries
Author: By
Last change: updated to work with changes
Date: 19 years ago
Size: 679 bytes
 

Contents

Class file image Download
<?php
   
// demonstrates the use of xmllib
   
require_once('xmllib.php');

   
// open and read file
   
$xml = new XmlLib_xmlParser('changelog.xml');
   
// parse document and return rootnode
   
$doc = $xml->getDocument();

    echo
"<h1>changelog</h1>\n";
    if (
$doc->hasChildren()) {
        for (
$i=0;$i<count($doc->children);$i++) {
           
// parse the node into associative array
           
$n = $doc->children[$i]->toArray();
            echo
"<h2>".htmlentities($n['title'])."</h2>\n";
            if (isset(
$n['date']))
                echo
"<p><em>&lt;".date("j F Y", strtotime($n['date']))."&gt;</em></p>\n";
            echo
"<p>".nl2br(htmlentities(trim($n['body'])))."</p>\n";
        }
    } else {
        echo
"log is empty";
    }
?>