Well performing some troubleshooting, I broke up the code into two different .php scripts just to see if they work independantly.
The XML Parsing script for some reason doesn't seem to be passing the variable in the xml function, even though I have it in the function as global.
Maybe I am assuming how variables work within a function
<?php
// setup xml parsing to read in pilot data
$current = "";
$pname = "";
$flights = "";
$miles = "";
$hours = "";
function start_tag($parser, $name, $attribs) {
global $current;
$current = $name;
}
function end_tag($parser, $name) {
global $current;
}
function tag_contents($parser, $data) {
global $current, $pname, $flights, $miles, $hours;
if ($current == "name") {$pname = $data;}
if ($current == "flights") {$flights = $data;
echo "$flights";}
if ($current == "miles") {$miles = $data;
echo "$miles";}
if ($current == "hours") {$hours = $data;
echo "$hours";}
}
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($parser, "start_tag", "end_tag");
xml_set_character_data_handler($parser, "tag_contents");
$document = file_get_contents("pathtomyxml/xml/pilots.xml","r")
or die("Error reading XML data.");
xml_parse($parser, $document);
xml_parser_free($parser);
echo "$pname";
?>
If I echo the variables in function tag_contents area, they appear, but when I echo it at the bottom, it does not.