[PHP] RSS to Array function
2012-04-16 22:15
281 查看
<?php $rss_tags = array( 'title', 'link', 'guid', 'comments', 'description', 'pubDate', 'category', ); $rss_item_tag = 'item'; $rss_url = 'http://www.pixel2life.com/feeds/adobe_fireworks.xml'; $rssfeed = rss_to_array($rss_item_tag,$rss_tags,$rss_url); echo '<pre>'; print_r($rssfeed); function rss_to_array($tag, $array, $url) { $doc = new DOMdocument(); $doc->load($url); $rss_array = array(); $items = array(); foreach($doc->getElementsByTagName($tag) AS $node) { foreach($array AS $key => $value) { $items[$value] = $node->getElementsByTagName($value)->item(0)->nodeValue; } array_push($rss_array, $items); } return $rss_array; } ?>
相关文章推荐
- [php function]arraytoString
- translate.php - Assocciative array example, passing a reference to a function
- Fatal error: Call to a member function fetch_array() on a non-object in E:\wamp\www\shop\index.php
- Call to undefined function php_ini_loaded_file()
- php数组转换为对象PHP - Convert Array to Object with stdClass
- Fatal error: Call to undefined function mysql_connect() (PHP连MYSQL)
- PHP连接MySQL错误:Call to undefined function mysql_connect()
- PHP Fatal error: Call to undefined function OCILogon()
- php连接mysql错误:Call to undefined function mysql_connect()
- Fatal error: Call to undefined function compile_str() in .../mobile/order.php或者输入地址后页面400错误
- mac下php编程出现php [function.move-uploaded-file]failed to open stream
- php mysql 配置过程 Fatal error: Call to undefined function mysql_connect()
- Call to undefined function set_magic_quotes_runtime() in /opt/app/apache/install/index.php:12 Stack
- php中出现“Call to a member function Execute() on a non-object”的问题
- phpmyadmin:Call to undefined function __() Config.class.php on line 755 解决办法
- PHP Warning: date() [function.date]: It is not safe to
- PHP 环境搭建要领 call to undefined function mysql_connect
- linux(ubuntu) php : call to undefined function mysql_connect
- Image To Byte Array Function
- php连接mysql报错——Fatal error: Call to undefined function mysql_connect() in