echo simplexml object

后端 未结 4 2056
失恋的感觉
失恋的感觉 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:07

    Part 1

    This is still not exactly what I wanted, but rather a very tidy and organized way of echoing the xml data:

        $url = "http://www.blogger.com/feeds/6552111825067891333/posts/default";
    $xml = simplexml_load_file($url);
    echo '
    ';
    print_r($xml);
    

    Part 2

    I had to get firephp running so I could see exactly what elements php was encountering when it reached an entry without a blog title. Ultimately it is an empty array. Therefore, the simple:

    if(empty($entry->title))
    

    works perfectly. For string comparison, I found that you can simply cast it as a string. For my purposes, that was unnecessary.

提交回复
热议问题