note 74456 added to ref.xml
| From: | phpzmurf | Date: | Thu, 12 Apr 2007 11:19:20 +0000 |
| Subject: | note 74456 added to ref.xml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125322@lists.php.net to get a copy of this message | ||
/*
* Parse rss news, quotes etc.
*
* author : phpZmurf <phpzmurf[at]yahoo.com>
* created: 12.04.2007
* ver : 1.0
*
*/
$data = implode("", file("http://feeds.feedburner.com/quotationspage/qotd/"));
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
# data saved here
$arrQuotes = array();
# at the beginig - the tag is set colsed
$tagOpen = false;
foreach($values as $key => $item) {
if(!$tagOpen and $item['tag'] == 'item' and $item['type'] ==
'open') {
# item tag opens
$tagOpen = true;
# empty temporary variables
$temp_title = '';
$temp_description = '';
$temp_guid = '';
$temp_link = '';
} elseif($item['tag'] == 'item' and $item['type'] ==
'close') {
# item tag ends
$tagOpen = false;
# if all 4 tags contain data... add them to output array
if($temp_title != '' and $temp_description != '' and $temp_guid !=
'' and $temp_link != '') {
$arrQuotes[] = array(
'title' => $temp_title,
'description' => $temp_description,
'guid' => $temp_guid,
'link' => $temp_link
);
}
} else {
# save data into temporary variables
switch($item['tag']) {
case 'title':
$temp_title = $item['value'];
break;
case 'description':
# this here quz there was a fuggin <p> at the end of the desription
#$temp_description = $item['value'];
$temp_description = substr($item['value'], 0,
strpos($item['value'], '<'));
break;
case 'guid':
$temp_guid = $item['value'];
break;
case 'link':
$temp_link = $item['value'];
break;
default: break;
}
}
}
foreach($arrQuotes as $key => $item) {
print_r($item);
}
----
Server IP: 212.47.220.13
Probable Submitter: 195.222.9.197 (proxied: 192.168.2.3)
----
Manual Page -- http://www.php.net/manual/en/ref.xml.php
Edit -- https://master.php.net/note/edit/74456
Del: integrated -- https://master.php.net/note/delete/74456/integrated
Del: useless -- https://master.php.net/note/delete/74456/useless
Del: bad code -- https://master.php.net/note/delete/74456/bad+code
Del: spam -- https://master.php.net/note/delete/74456/spam
Del: non-english -- https://master.php.net/note/delete/74456/non-english
Del: in docs -- https://master.php.net/note/delete/74456/in+docs
Del: other reasons-- https://master.php.net/note/delete/74456
Reject -- https://master.php.net/note/reject/74456
Search -- https://master.php.net/manage/user-notes.php