0
<?php
## Loop through results from mysql
try{
    #connection string
        // $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=mydb',array(PDO::ATTR_PERSISTENT => true));
        $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=mydb','user','pass',array(PDO::ATTR_PERSISTENT => true));
        $q = $dbconn->prepare("SELECT FW_ArtSrcLink FROM FW_ArtSrc WHERE OneSet=1 and leagID=20");
    #call stored proc
        $q->execute();
    #get the rows into an array
        $result = $q->fetchAll();
        $newsStory = array();
    foreach($result as $r){
        $xmlUrl = $r['FW_ArtSrcLink'];
        $ConvertToXml = simplexml_load_file($xmlUrl);
        # -> Setup XML
        $newsStory[] = $ConvertToXml->channel->item;
    }
    # -----> Load News Stories
        for($i = 0;$i<sizeof($newsStory); $i++){

    # Source of Article Info-->
            $SrcTitle=$newsStory[$i]->title;
            $SrcLink=$newsStory[$i]->link;

    # Actual News Article Info -->
            $title=$newsStory[$i]->title;
            $desc=$newsStory[$i]->description;

    # Output Results ------------>      
            echo '<hr>';
            echo '<strong>'.'Title:'.$title.'</strong>'.'(via: <a href=\''.$SrcLink.'\'>'.$SrcTitle.'</a>'.'<br />';
            //echo 'Link:'.$link.'<br />';
            echo 'Description'.$desc.'<br>';
            ##echo 'count '.count($result);
            echo '<hr>';

            # echo 'sizeof newstory: '.sizeof($newsStory);
        }   // for()
} // try

使用我想使用类似从每个链接收集所有s 的foreach($result as $r)东西来获取所有 xml 项目。我该怎么做?$ConvertToXml->channel->item;item

4

0 回答 0