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

  • SEARCH
  • Home
  • 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 8180541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:14:09+00:00 2026-06-07T00:14:09+00:00

I am trying to get rss feed and push the node value to an

  • 0

I am trying to get rss feed and push the node value to an array. I though my following php codes would create a single array instead of multi-dimensional array.

 //parse rss
    $contents= file_get_contents('http://rss..');
    $xmlStr= simplexml_load_string($contents); 


    $array=array();
          foreach ($xmlStr->item as $node):

                  $array[]=$node->title;

                 echo '<pre>';
                    print_r($array);
                 echo '<pre>';


           endforeach;

but turns out my array output is

Array
(
    [0] => SimpleXMLElement Object
        (
            [0] => App Store Bug Corrupts Binaries; Angry Birds Crash
        )

    [1] => SimpleXMLElement Object
        (
            [0] => In UK, HTC Defeats Apple's "Obvious" Slide Unlock Patent
        )

    [2] => SimpleXMLElement Object
        (
            [0] => WikiLeaks Begins Release of 2.5m Syrian Emails
        )

    [3] => SimpleXMLElement Object
        (
            [0] => A Critical Examination of Bill Gates' Philanthropic Record
        )

    [4] => SimpleXMLElement Object
        (
            [0] => Ask Slashdot: How Does Your Company Evaluate Your Performance?
        )

    [5] => SimpleXMLElement Object
        (
            [0] => UAV Cameras an Eye In the Sky For Adventurous Filmmakers
        )

    [6] => SimpleXMLElement Object
        (
            [0] => Copyrights To Reach Deep Space
        )

    [7] => SimpleXMLElement Object
        (
            [0] => FDA Approves HIV Home-Use Test Kit
        )

    [8] => SimpleXMLElement Object
        (
            [0] => Texas Scientists Regret Loss of Higgs Boson Quest
        )

    [9] => SimpleXMLElement Object
        (
            [0] => Icelandic MP Claims US Vendetta Against WikiLeaks
        )

    [10] => SimpleXMLElement Object
        (
            [0] => Microsoft's 'Cannibalistic Culture'
        )

    [11] => SimpleXMLElement Object
        (
            [0] => Android 4.1 Jelly Bean Review
        )

)

Any idea how to change this? Thanks a lot.

  • 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-06-07T00:14:11+00:00Added an answer on June 7, 2026 at 12:14 am

    You will need to cast each node to a string (it is currently a SimpleXMLElement) in order to get back a plain string in a simple array, and retrieve the first item from the title[] array.

    SimpleXML implements __toString() magic methods on its objects, which is why it will respond the way it does to print_r(), but to use retrieve it as a string you need to cast it as such.

    foreach ($xmlStr->item as $node):
       // Cast the first array value to a string
       $array[] = (string)$node->title[0];
       echo '<pre>';
         print_r($array);
       echo '<pre>';
    endforeach;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do a rss feed in cakephp. I get the xml in
I am unsure how to get the value of dc:creator from an RSS-feed using
I am trying with the code below to get a bing rss news feed,
I'm trying to create an image gallery from an rss feed with the galleryview
Im trying to create a RSS feed reader for a project that I working
I am currently trying to display a RSS feed in a PHP page, but
I am trying to get an rss feed into my iphone app. I was
I am trying to get some data from a RSS feed but I am
I'm trying to get the entry->id and entry->cap:parameter->value for every entry in the RSS
I am trying to create a rss feed from a web page. I am

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.