<?
// 
// $Id:  $
//
// Definition of eZNewsXML support functions.
//
// Paul K Egell-Johnsen <pkej@ez.no>
// Created on: <28-Sep-2000 13:42:10 pkej>
//

include_once( "eznews/classes/eznewsxmlfunctions.php" );
global $theXMLParser;
global $data;

// declare the character set - UTF-8 is the default
$type = 'US-ASCII';
$type = 'ISO-8859-1';
$type = 'UTF-8';

// create our parser
$xml_parser = xml_parser_create($type);


// set some parser options 
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $type);

// this tells PHP what functions to call when it finds an element
// these funcitons also handle the element s attributes
xml_set_element_handler($xml_parser, 'startElement','endElement');

// this tells PHP what function to use on the character data
xml_set_character_data_handler($xml_parser, 'characterData');

#if (!($fp = fopen($xml_file, 'r'))) {
#    die("Could not open $xml_file for parsing!\n");
#}
// loop through the file and parse baby!

    if( !( $data = utf8_encode($data) ) )
    {
        
    }
    
    if( !xml_parse( $xml_parser, $data ) )
    {
        die(sprintf( "XML error: %s at line %d\n\n",
        xml_error_string(xml_get_error_code($xml_parser)),
        xml_get_current_line_number($xml_parser)));
    }

xml_parser_free($xml_parser);
?>
