kney Posted April 29, 2011 Share Posted April 29, 2011 XML Parsing Error: junk after document element Location: http://localhost:8080/php/script.php?file=test Rule Number 6, column 1: <?php session_start(); define("CONST1", 5); define("CONST2", 10); define("CONSTERROR", false); define("REFRESH_TIME", 2); if(isset($_SESSION['views'])){ $_SESSION['views']=$_SESSION['views']+1; }else{ $_SESSION['views']=1; } if(!isset($_SESSION['decision'])){ $_SESSION['decision'] = rand(1, CONST2); } function respond_xml($status, $message) { $out = new XMLWriter(); $out->openURI("php://output"); $out->setIndent(true); $out->startDocument("1.0", "ISO-8859-1"); $out->startElement("statuscheck"); $out->writeElement("status", $status); $out->writeElement("message", $message); $out->endElement(); $out->endDocument(); $out->flush(); } function main() { header("Refresh: " . REFRESH_TIME . "; URL=http://localhost:8080/php/script.php?file=test"); header("Content-type: text/xml"); if (!isset($_GET["file"])) respond_xml("ERROR", "File parameter missing"); while($_SESSION['views'] < CONST1){ respond_xml("NOT OK", "File does not exist. "); } if($_SESSION['views'] >= CONST1 && CONSTERROR == true){ respond_xml("ERROR", "Some error has occured!"); } else{ if($decision == 1){ respond_xml("OK", "File exists. Decision: " . $_SESSION['decision']); } else{ respond_xml("NOT OK", "File does not exist. Decision: " . $_SESSION['decision']); } } } main(); ?> Link to comment https://forums.phpfreaks.com/topic/235064-xml-error/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.