How to echo xml file in php

前端 未结 10 856
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 04:37

How to print an xml file to the screen in php?

This is not working:

$curl = curl_init();        
curl_setopt ($curl, CURLOPT_URL, \'http://rss.news.y         


        
10条回答
  •  -上瘾入骨i
    2020-11-29 05:02

    If anyone is targeting yahoo rss feed may benefit from this snippet

     $Items) {
        for($i = 0; $i < $level; $i++)
        echo(" ");
        /*if content more than one*/
        if(!is_array($Items)){
        //$Items=htmlentities($Items); 
        $Items=htmlspecialchars($Items);
        echo("Item " .$key . " => " . $Items . "

    "); } else { echo($key . " =>

    "); PrettyPrintArray($Items, $level+1); } } } PrettyPrintArray($featureRss, 0); ?>

    You may want to run it in your browser first to see what is there and before looping and style it up pretty simple

    To grab the first item description

    
    

    You can see a demo here

提交回复
热议问题