PHP Classes
Icontem

File: changelog.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of troels knak-nielsen  >  xmllib  >  changelog.php  
File: changelog.php
Role: Example script
Content type: text/plain
Description: demonstration
Class: xmllib
Parse XML documents without external libraries
 

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";
    }
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products