localendar Forums Homepage

Print at Aug 26, 2025, 4:43:30 AM View all posts in this thread on one page
Posted by janaballard at Oct 14, 2005, 3:26:23 AM
parsing xml feed with php in safari or firefox
hi,

i'm trying to parse the xml feed for one of my client's localendars - i can view the xml via safari and firefox but when i try to open the xml via php's fopen function i am unable to open the file. is there something special that i must do to be able to open the xml file remotely?

any help here would be greatly appreciated.

jana

ps i know my php code works because i can open practically any other url with the fopen function call EXCEPT localendar.com.

Posted by janaballard at Oct 14, 2005, 11:59:21 AM
Re: parsing xml feed with php in safari or firefox
i think this has something to do with the tomcat server... i just found this article but it doesn't provide a work-around - http://bugs.php.net/bug.php?id=7373&edit=1

Posted by janaballard at Oct 15, 2005, 9:36:04 PM
Re: parsing xml feed with php in safari or firefox
Is anyone at localcalendar familiar with the tomcat bug? Can anyone help me with this?

Posted by support at Oct 18, 2005, 11:19:46 AM
Re: parsing xml feed with php in safari or firefox
I can't find a similar issue on Apache's site; and that bug report is from 5 years ago.

I've had to massage enough HTML and XML over the years to know depending on a particular space is a tenuous decision at best.

I think the original poster misinterprets the HTTP spec:
 
each element separated by SP


since there is no element after the status code (200), there is no requirement for the trailing space, so I would argue PHP is incorrent in this instance.

Anyway, what matters is that the site doesn't work for your needs. You can certainly submit it as a bug to Apache, but I would also look to see if there are PHP alternatives to fopen.
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news

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.

Posted by support at Oct 24, 2005, 11:23:30 AM
Re: parsing xml feed with php in safari or firefox
Thanks for your work on this. Please let me know what direction this takes and any assitance we can provide.
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news


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