Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:58:20+00:00 2026-05-22T02:58:20+00:00

I am trying to include a php parser that will retrieve a rss 2.0

  • 0

I am trying to include a php parser that will retrieve a rss 2.0 file:

<?php

  $doc = new DOMDocument();
  $doc->load('http://www.domain.com/blog/feed/');
  $arrFeeds = array();
  foreach ($doc->getElementsByTagName('item') as $node) {
    $itemRSS = 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($arrFeeds, $itemRSS);
  }

//And trying to parse the return into a template:

$view_doc->assign("DOCID", $arrFeeds);

?>

But the output given is simply “Array” 🙁

I hope that you can give me some hints guys 🙂

Kind Regards!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:58:21+00:00Added an answer on May 22, 2026 at 2:58 am

    Remove $docidtrue = return $arrFeeds; and replace $docidtrue with $arrFeeds. It should work as you wanted.

    It would look like that:

    <?php
    
    $doc = new DOMDocument();
    $doc->load('http://www.domain.com/blog/feed/');
    $arrFeeds = array();
    foreach ($doc->getElementsByTagName('item') as $node) {
        $itemRSS = 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($arrFeeds, $itemRSS);
    }
    
    //And trying to parse the return into a template:
    
    $view_doc->assign("DOCID", $arrFeeds);
    
    ?>
    

    return is not what you wanted. Maybe you looked for break (which exits the whole current loop) or continue (which leaves current loop iteration and goes to the next one).

    EDIT:

    Because you need some string to be passed to assign() method, we can make something that will display the list of items instead of gathering them for further processing 🙂

    <?php
    
    $doc = new DOMDocument();
    $doc->load('http://www.domain.com/blog/feed/');
    $feeds = '';
    foreach ($doc->getElementsByTagName('item') as $node) {
        $feeds .= '<div>'
            .'<h2>'.$node->getElementsByTagName('title')->item(0)->nodeValue.'</h2>' // title
            .'<p>'.$node->getElementsByTagName('description')->item(0)->nodeValue.'</p>' // desc
            .'<p><a href="'.$node->getElementsByTagName('link')->item(0)->nodeValue.'">link</a></p>' // link
            .'<p>'.$node->getElementsByTagName('pubDate')->item(0)->nodeValue.'</p>' // date
            .'</div>';
    }
    
    //And trying to parse the return into a template:
    
    $view_doc->assign("DOCID", $feeds);
    
    ?>
    

    This has to work 🙂

    But remember – what I just did is just wrong. You should parse the variable resulting from the original solution within the template. I have just created it in the wrong place and passed generated string into the view. View is just for transforming data into displayable code (HTML).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate php files that 'include' a template html file, as so:
Below are the files in PHP that I am trying to include a file
I was trying to load a php file in html such that the menu
I am trying to include a .js file into a php file. My folder
I am trying to include the Zend_Service_Amazon_S3 file by using require_once 'Zend/Service/Amazon/S3.php'; I have
I'm trying to do a bit of fancy/experimental php so that you can include
I'm trying to include an EPS figure in a document that will be compiled
I'm trying to include a PHP file called includes.php which is not contained within
Background I am trying to include an rss feed using php into a html
I'm trying to cobble together a php style include function for javascript. The route

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.