Re: $35 to the first person who can do this XML-parsing PHP script
| From: | Tijnema ! | Date: | Thu, 08 Mar 2007 21:12:13 +0000 |
| Subject: | Re: $35 to the first person who can do this XML-parsing PHP script | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250127@lists.php.net to get a copy of this message | ||
On 3/8/07, Chris Shiflett <shiflett@php.net> 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