(It does not seem to like the var $insidegroup = false;
In fact, I have not gotten it to like ANYTHING other than a blank line, a comment, or a '}')
What am I missing?
My code (php version 4.2.3):
Code: Select all
<html>
<head>
<title>Group info parser</title>
</head>
<body>
<h2>Parsing group.xml</h2>
<?php
class GROUPParser {
// following items are unique to the group.
var $insidegroup = false;
var $tag = "";
var $groupID = "999999"; // will be used as reference by subscriber
// default value - overwritten if optional
// groupID tag is included in the xml
var $grName = "";
var $grStart = "";
var $grExpire = "";
var $grMax = "";
// following items will be unique to subscribers
var $suLastName = "";
var $suFirstName = "";
// following items are necessary for housekeeping
var $subscriberCount = 0;
function startElement($parser, $tagName, $attrs) {
if ($this->insidegroup) {
$this->tag = strtoupper($tagName);
} elseif (strtoupper($tagName) == "GROUP" || strtoupper($tagName) == "subscriber") {
$this->insidegroup = true;
}
}
function endElement($parser, $tagName) {
if (strtoupper($tagName) == "GROUP") {
if ($groupID != "999999")
printf("There is already a groupID, so we will just add subscribers to this group.");
else
printf("Here is where we add the group to the database and get the groupID.");
printf("Here is where we add the final SQL to adjust groupID's for subscribers.");
}
// now we reinitialize everything to be ready for other groups in same xml document
$this->tag = "";
$this->groupID = "999999";
$this->grName = "";
$this->grStart = "";
$this->grExpire = "";
$this->grMax = "";
$this->insideitem = false;
} elseif (strtoupper($tagName) == "SUBSCRIBER") {
if ($this->subscriberCount == $this->grMax) {
printf("Warning -- Too many subscribers for this group - subscriber skipped!");
} else {
printf("Here is a line of SQL to insert one subscriber.");
$this->subscriberCount += 1;
}
$this->suLastName = "";
$this->suFirstName = "";
}
}
function characterData($parser, $data) {
if ($this->insidegroup) {
switch ($this->tag) {
case "GROUPID":
$this->groupID .= $data;
break;
case "GRNAME":
$this->grName .= $data;
break;
case "GRSTART":
$this->grStart .= $data;
break;
case "GREXPIRE":
$this->grExpire .= $data;
break;
case "GRMAX":
$this->grMax .= $data;
break;
case "SULASTNAME":
$this->suLastName .= $data;
break;
case "SUFIRSTNAME":
$this->suFirstName .= $data;
break;
}
}
}
}