PHP利用RSS订阅别处文章
这篇文章是接上篇利用PHP操作XML文件的。RSS是基于XML的一种形式,它的具体规范如下(我们以截取的新浪RSS订阅频道的格式来看):
输入:http://rss.sina.com.cn/news/world/focus15.xml 查看页面源码就可以看到RSS的结构:
http://news.sina.com.cn/world
http://news.sina.com.cn/491/2008/0827/1.html
http://go.rss.sina.com.cn/redirect.php?url=http://news.sina.com.cn/w/2012-12-22/120825871683.shtml
虽然这次投票在法律上不具备约束力,但是人权活动分子说,每两年举行一次的表决,是向那些依然保留死刑的国家发出的强烈信号,这些数量在逐步减少的国家....]]>
具体规范信息是代表什么意思,根据标签的内容我们就可以很容易的知道,下面我们写一个rss.php来读取这个xml,从而获取这上面的文章:
$dom = simplexml_load_file("http://rss.sina.com.cn/news/world/focus15.xml");
//var_dump($dom);
?>
The example of RSS
- ");
print("");
print($item->title);
print("");
print(" ");
foreach($dom->channel->item as $item)
{
print("
}
?>
注意这个函数:simplexml_load_file() ; 它既可以读本地的xml文件,也可以读网络上的xml。
运行结果:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This chapter deals with the information about the authentication process available in CakePHP.
