localendar Forums Homepage


Print at Aug 26, 2025, 11:41:29 PM

Posted by janaballard at Oct 21, 2005, 2:13:26 PM
Re: parsing xml feed with php in safari or firefox
This is the exact error I'm getting:

Warning: fopen(http://www.localendar.com/public/BFNEP?style=M3) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /Library/WebServer/Documents/Projects/cultivating-youth/testing/xml_parser.php on line 29

Any other url I give the fopen function works - and since this is a SERVER error (and it's localendar's url not a file on my local machine), I am really thinking this is a problem on localendar's end... perhaps some port or permissions need to be changed on the file so that it can be accessed differently - (I'm no browser whiz but maybe this has to do with user-agents and authentication or something...)

For reference, here is my code:

<pre>
<?

error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", true);
//phpinfo();
$file = "http://www.localendar.com/public/BFNEP?style=M3";

$depth = array();

function startElement($parser, $name, $attrs)
{
global $depth;
for ($i = 0; $i < $depth[$parser]; $i++) {
echo " ";
}
echo "$name\n<BR>";
$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);


?>
</pre>

I will post this issue to a PHP specific forum as well to see if it's a PHP thing. Thanks again for your help.

Help! | Cobranding | Legal | Privacy Policy | About localendar.com | Contact Us