示例#1
0
    array_pop($stack);
}
function new_xml_parser($live)
{
    global $parser_live;
    $xml_parser = xml_parser_create();
    xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    if (!is_array($parser_live)) {
        settype($parser_live, "array");
    }
    $parser_live[$xml_parser] = $live;
    return array($xml_parser, $live);
}
# go parsing
if (!(list($xml_parser, $live) = new_xml_parser($live))) {
    die("could not parse XML input");
}
foreach ($output as $data) {
    if (!xml_parse($xml_parser, $data)) {
        die(sprintf("XML error: %s at line %d\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
    }
}
xml_parser_free($xml_parser);
#print_r($stack);
#exit;
#searching for rooms/fs20/Logpaths
$rooms = array();
$fs20devs = array();
$fhtdevs = array();
$logpaths = array();
示例#2
0
function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId)
{
    if ($systemId) {
        if (!(list($parser, $fp) = new_xml_parser($systemId))) {
            printf("Could not open entity %s at %s\n", $openEntityNames, $systemId);
            return false;
        }
        while ($data = fread($fp, 4096)) {
            if (!xml_parse($parser, $data, feof($fp))) {
                printf("XML error: %s at line %d while parsing entity %s\n", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser), $openEntityNames);
                xml_parser_free($parser);
                return false;
            }
        }
        xml_parser_free($parser);
        return true;
    }
    return false;
}