On 3/8/07, Chris Shiflett <[EMAIL PROTECTED]> wrote:

Rob Gould wrote:
> I'll send $35 to someone via paypal who can create a PHP script that
> will do the following:
>
> 1)  Read XML data from an URL (
www.librarytools.com/events/sampledata.txt)
> 2)  Loop through all XML results and print to the screen the "eventname"
> and "eventnextoccurrencedate" (Just the date) values

<table>
   <tr><th>Name</th><th>Date</th></tr>

<?php

$xml = simplexml_load_file('http://librarytools.com/events/sampledata.txt'
);


here you are using a PHP 5 function, and he said he was only using PHP 4.4.4
So this script won't work for him.

foreach ($xml->source->result as $f) {
   $name = '?';
   $date = '?';

   foreach ($f as $event) {
       if ($event['n'] == 'eventname') {
           $name = $event;
       } elseif ($event['n'] == 'eventnextoccurrencedate') {
           $date = date('D, M d Y H:i:s', strtotime($event));
       }
   }

   echo "    <tr><td>{$name}</td><td>{$date}</td></tr>\n";
}

?>

</table>

Gotta love SimpleXML. :-)

--
Chris Shiflett
http://shiflett.org/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Reply via email to