Hi everyone, I am trying to get this script from www.sitepoint.com to work, but there is a parse error in Line 72, which only contains </html>! It is slowly driving me mad, can anyone see what I've done wrong?
Thanks in advance.
<?php
function extractText($array){
if(count($array) <= 1){
//we only have one tag to process!
for ($i = 0; $i<count($array); $i++){
$node = $array[$i];
$value = $node->get_content();
}
return $value;
}
}
?>
<html>
<head>
<title>Welcome to XMLTEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h1>Welcome to the XMLTEST site</h1>
<p><br>
<a href="adminindex.php">Admin Login</a> </p>
<form name="search" method="post" action="searchArticles.php">
Search articles:
<input name="search" type="text" id="search">
<input name="Search" type="submit" id="Search" value="Search">
</form>
<p>The following articles are available: </p>
<table border=1 cellspacing=0 cellpadding=2 width=500>
<?php
$dh = opendir('c:\Program Files\Apache Group\Apache2\htdocs\estimates\xml\');
$fileCount = 0;
while ($file = readdir($dh) and $fileCount <= 5){
if (eregi("^\\.\\.?$", $file)) {
continue;
}
$open = "c:\Program Files\Apache Group\Apache2\htdocs\estimates\xml\".$file;
$xml = domxml_open_file($open);
//we need to pull out all the things from this file that we will need to
//build our links
$root = $xml->root();
$stat_array = $root->get_elements_by_tagname("status");
$status = extractText($stat_array);
$ab_array = $root->get_elements_by_tagname("abstract");
$abstract = extractText($ab_array);
$h_array = $root->get_elements_by_tagname("headline");
$headline = extractText($h_array);
if ($status != "live"){
continue;
}
echo "<tr valign=top><td>";
echo "<a href=\"showArticle.php?file=".$file . "\">".$headline . "</a><br>";
echo $abstract;
echo "</td></tr>";
echo $fileCount++;
}
echo "</table>";
echo "<br><a href=\"adminindex.php\">Admin Login</a>";
echo "</body></html>";
?>