and help Easy Net RSS reading is in this program based on a little to do the transformation, the main
If you output an array string and solve the encoding problem.
The PHP source code and code are explained in detail as follows:
<?php
An array of RSS source address lists
$rssfeed = Array ("Http://www.jb51.net/feed",
"Http://rss.sina.com.cn/news/allnews/sports.xml",
"Http://ent.163.com/special/00031K7Q/rss_toutiao.xml",
"Http://tech.163.com/special/00091JPQ/techimportant.xml");
Set Encoding to UTF-8
Header (' content-type:text/html;charset= UTF-8 ');
for ($i =0; $i <sizeof ($rssfeed); $i + +) {//Explode start
$buff = "";
$rss _str= "";
Open the RSS address and read, the read failed to abort
$fp = fopen ($rssfeed [$i], "R") or Die ("Can not open $rssfeed");
while (!feof ($fp)) {
$buff. = Fgets ($fp, 4096);
}
Close File Open
Fclose ($FP);
Create an XML parser
$parser = Xml_parser_create ();
Xml_parser_set_option--option settings for specified XML parsing
Xml_parser_set_option ($parser, xml_option_skip_white,1);
Xml_parse_into_struct-parsing XML data into an array $values
Xml_parse_into_struct ($parser, $buff, $values, $IDX);
Xml_parser_free--Frees the specified XML parser
Xml_parser_free ($parser);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.