when i'm running this script copy from php manual xml chapter:
################################
xmltest.php
<?
Example 1. Show XML Element Structure
$file = "data.xml";
$depth = array();
function startElement($parser, $name, $attrs) {
global $depth;
for ($i = 0; $i < $depth[$parser]; $i++) {
print " ";
}
print "$name\n";
$depth[$parser]++;
}
function endElement($parser, $name) {
global $depth;
$depth[$parser]--;
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
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)));
}
}
xml_parser_free($xml_parser);
?>
##############################
data.xml
<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY testEnt "test entity">
]>
<foo>
<element attrib="value"/>
&testEnt;
<?php print "This is some more PHP code being executed."; ?>
</foo>
i'll get a page not find error.
When i check the error logs of the Apache, i found that error :
[Sat Feb 24 11:57:16 2001] [notice] child pid 4402 exit signal Segmentation fault (11)
However, when i replace data.wml to an empty file. The script will return this error message:
XML error: no element found at line 1
i traced that the problem should cause by "xml_parse".But Why?
i'm using linux + apache + php4.04 compiled with xml.
Please help.