echo simplexml object

后端 未结 4 2054
失恋的感觉
失恋的感觉 2021-01-14 21:21

This question has two parts.

Part 1. Yesterday I had some code which would echo the entire content of the XML from an RSS feed. Then I deleted it fr

4条回答
  •  无人共我
    2021-01-14 22:02

    Part 1: echo $xml->asXML(); - http://www.php.net/manual/en/simplexmlelement.asxml.php

    Part 2: php SimpleXML check if a child exists

    $html .= "

    ".($entry->title!=null?$entry->title:'No Title') . " | " .$pubDate . "

    " . $entry->content . "

    ";

    Note I would probably load the url like this:

    $feedUrl = 'http://www.blogger.com/feeds/6552111825067891333/posts/default';
    $rawFeed = file_get_contents($feedUrl);
    $xml = new SimpleXmlElement($rawFeed);
    

    Based on your comment in regards to part 1, I am not sure if the XML is being loaded completely. If you try loading it this way, it should display all the XML data.

提交回复
热议问题