Home > Backend Development > PHP Tutorial > !怎么用PHP获取RSS阅读器里CDATA部分的内容

!怎么用PHP获取RSS阅读器里CDATA部分的内容

WBOY
Release: 2016-06-13 10:14:50
Original
904 people have browsed it

紧急求助!!~如何用PHP获取RSS阅读器里CDATA部分的内容
如题~
阅读器地址:http://rss.weather.gov.hk/rss/CurrentWeather_uc.xml
我要获取CDATA里温度,紫外线,相对湿度等内容,该如何搞定~?



------解决方案--------------------

PHP code
$str=file_get_contents('http://rss.weather.gov.hk/rss/CurrentWeather_uc.xml');preg_match('/\[CDATA\[\s*<p>(.*)</p><p>/Uis',$str,$match);print_r($match[1]);<br><font color="#e78608">------解决方案--------------------</font><br>互联网真是好东西啊!参考文档:搜索“用simpleXML 如何读取 中的内容呢”</p>
Copy after login
PHP code
$url = 'http://rss.weather.gov.hk/rss/CurrentWeather_uc.xml';$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA); print_r($xml->channel->item->description);<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template