<?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><".date("j F Y", strtotime($n['date']))."></em></p>\n";
echo "<p>".nl2br(htmlentities(trim($n['body'])))."</p>\n";
}
} else {
echo "log is empty";
}
?>
|