Welcome Guest   | Login   
  Search  
  Index |  Recent Threads |  Register | 


Quick Go »
Thread Status: Normal
Total posts in this thread: 6
[Change thread status] [Delete this Thread] [Move this Thread]
[Add To My Favorites] [Watch this Thread] [Post new Thread]
Author
Previous Thread This topic has been viewed 184 times and has 5 replies Next Thread
janaballard
New Member



Joined: Oct 14, 2005
Posts: 4
Status: Offline

Edit this Post   parsing xml feed with php in safari or firefox Reply to this Post
Reply with Quote
[Delete this Thread]

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.
[Oct 14, 2005, 3:26:23 AM] [67.160.103.192] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
janaballard
New Member



Joined: Oct 14, 2005
Posts: 4
Status: Offline

Edit this Post   Re: parsing xml feed with php in safari or firefox Reply to this Post
Reply with Quote
[Delete this Post]

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
[Oct 14, 2005, 11:59:21 AM] [207.229.83.184] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
janaballard
New Member



Joined: Oct 14, 2005
Posts: 4
Status: Offline

Edit this Post   Re: parsing xml feed with php in safari or firefox Reply to this Post
Reply with Quote
[Delete this Post]

Is anyone at localcalendar familiar with the tomcat bug? Can anyone help me with this?
[Oct 15, 2005, 9:36:04 PM] [24.18.213.1] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Aug 9, 2022
Posts: 6437
Status: Offline
Edit this Post   Re: parsing xml feed with php in safari or firefox Reply to this Post
Reply with Quote
[Delete this Post]

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
[Oct 18, 2005, 11:19:46 AM] [70.107.233.250] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
janaballard
New Member



Joined: Oct 14, 2005
Posts: 4
Status: Offline

Edit this Post   Re: parsing xml feed with php in safari or firefox Reply to this Post
Reply with Quote
[Delete this Post]

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.
[Oct 21, 2005, 2:13:26 PM] [67.160.103.192] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Aug 9, 2022
Posts: 6437
Status: Offline
Edit this Post   Re: parsing xml feed with php in safari or firefox Reply to this Post
Reply with Quote
[Delete this Post]

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
[Oct 24, 2005, 11:23:30 AM] [70.107.233.250] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
[Show Thread Printable Version] [Post new Thread]

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