main():和SimpleXMLElement :: __ toString():节点不再存在和

时间:2017-04-06 09:42:40

标签: php xml rss simplexml main

我有PHP代码,它正在创建xml feed并为bootstap创建一个html

<?php
    $x = 0;
// get how many feeds are displayed
if (!$_GET) {
    $numfeeds = 13;
} else {
    $numfeeds = $_GET["numfeeds"];
}

// feed information
$html = "";
$url = "  // a url to xml feed \\  ";
$xml = simplexml_load_file($url);
for ($i = $x; $i < $numfeeds; $i++) {
    $portitem = "<div class='col-md-4 portfolio-item'>";
    if ($x <= 3) echo $portitem;
    $image = $xml->channel->item[$i]->children('media', True)->content->attributes();
    if (empty($image)) echo 'images/banana.jpg';

    $title = $xml->channel->item[$i]->title;
    $link = $xml->channel->item[$i]->link;
    $pubDate = $xml->channel->item[$i]->pubDate;
    $author = $xml->channel->item[$i]->author;
    $description = $xml->channel->item[$i]->description;

    if (!$x++) echo $portitem;
    if ($x % 4 == 0) echo $portitem;
    $html .= html_entity_decode("
                <br>
                $portitem
                <div>
                    <p>
                    <p>$pubDate, $author</p>
                    <a href='$link'><H2>$title</H2></a></div> <br>
                     <a href='$link'>
                         <img class='img-responsive' src='$image' alt=''>
                     </a>
                    <p>$description</p>
                    </p>
                </div>
                </div>
                <br>");
    $x++;
    if ($x % 4 == 0) echo '</div>';
}
echo print_r($html);

?>
一切似乎都在起作用,我希望以格式提供te,但它也给了我两个错误:

  • main():第25行的rss.php中不再存在节点
  • SimpleXMLElement :: __ toString():第47行rss.php中不再存在节点

我该如何处理它们?有快速解决方法吗?

0 个答案:

没有答案