The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End DOMDocument load eror handling

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #46081

    I want to protect my function from displaying errors when something is wrong loading external files but I can’t find any documentation about this.

    Here’s the code:
    $rss = new DOMDocument();

    $feed = array();
    foreach ($rss->getElementsByTagName(‘item’) as $node) {
    $item = array (
    ‘title’ => $node->getElementsByTagName(‘title’)->item(0)->nodeValue,
    ‘desc’ => $node->getElementsByTagName(‘description’)->item(0)->nodeValue,
    ‘link’ => $node->getElementsByTagName(‘link’)->item(0)->nodeValue,
    ‘date’ => $node->getElementsByTagName(‘pubDate’)->item(0)->nodeValue,
    array_push($feed, $item);

    return $feed;


    In _this_ case hidding _is_ error handling. But not with display_errors off.

    I want to ensure that when the source of my feed goes down or change the structure of their xml document I’m able to hide the feed box from the website. Isn’t there any “try{ } catch{}” similar in PHP?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.