Hi all
I am using the following parse to shift through a document
$file = "content.txt";
$startTags = array(
"PAGE" => "<tr><td valign=\"top\"><FONT FACE=\"Verdana, Helvetica, Arial\" SIZE=\"-1\"><SPAN CLASS=\"main\">",
"PAGENUMBER" => "<!-- ",
"NAME" => "",
"LINK" => "<!-- ",
"CONTENT" => "<!-- "
);
// close tags opened above
$endTags = array(
"PAGE" => "",
"PAGENUMBER" => " -->",
"NAME" => "</td>",
"LINK" => " -->",
"CONTENT" => " --><td valign=\"top\"><FONT FACE=\"Verdana, Helvetica, Arial\" SIZE=\"-1\"><SPAN CLASS=\"main\"><a href=\"content2.php\"><img src=\"images/edit.gif\" width=\"9\" height=\"11\" alt=\"Edit Page\" border=\"0\"></a> <a href=\"#\"><img src=\"images/delpageicon.gif\" width=\"9\" height=\"11\" alt=\"Delete Page\" border=\"0\"></a></td></tr>"
);
function startElement($parser, $name, $attrs) {
global $startTags;
// if tag exists as key, print value
if ($startTags[$name]) { echo $startTags[$name]; }
}
function endElement($parser, $name) {
global $endTags;
if ($endTags[$name]) { echo $endTags[$name]; }
}
// process data between tags
function characterData($parser, $data) {
echo $data;
}
// initialize parser
$xml_parser = xml_parser_create();
// set callback functions
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
// open XML file
if (!($fp = fopen($file, "r")))
{
die("Cannot locate XML data file: $file");
}
// read and parse data
while ($data = fread($fp, 4096))
{
// error handler
if (!xml_parse($xml_parser, $data, feof($fp)))
{
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
// clean up
xml_parser_free($xml_parser);
The problem is, that in the results I would like to create a variable called $idd which would be associated with the number in area PAGENUMBER
Been racking my brains on how to do it and have completely failed. Has anyone any ideas or alternative suggestions, since the results have to be displayed in table format