Date: 03/27/00
- Next message: Mark Musone: "[PHP-DEV] cvs: /php3 CREDITS"
- Previous message: Ben Mansell: "[PHP-DEV] Zeus support for PHP4"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: akl <email protected>
Operating system: Linux RedHat 6.0
PHP version: 3.0.15
PHP Bug Type: Parser error
Bug description: with xml: can't read variable value inside if
I have a file.xml with <EMAIL>char_data</EMAIL>. Calling the script: http://server/script.php3?file.xml . In function characterData variable $data is empty when it's echoed inside if:
<?php
$filename = $argv[0];
$double = FALSE;
function startElement($parser, $name, $attribs)
{
global $double;
echo "<DIV CLASS=\"$name\">\n";
if ($name == "EMAIL")
$double = TRUE;
/* string inside <EMAIL></EMAIL> has to be displayed twice */
}
function endElement($parser, $name)
{
echo "</DIV>\n";
}
function characterData($parser, $data)
{
global $double;
if ($double)
{
echo "IF: ","$data"," :ENDIF";
/* IF: and ENDIF: are displayed but $data is empty */
$double = FALSE;
}
echo "$data"; /* here $data is ok*/
}
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($file = fopen($filename, "r")))
die("could not open XML input");
while ($data = fread($file, 4096))
{
if (!xml_parse($xml_parser, $data, feof($file)))
{
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
?>
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Mark Musone: "[PHP-DEV] cvs: /php3 CREDITS"
- Previous message: Ben Mansell: "[PHP-DEV] Zeus support for PHP4"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

