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 8704523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:07:39+00:00 2026-06-13T03:07:39+00:00

I’m trying to read a few RSS feed details from a XML file with

  • 0

I’m trying to read a few RSS feed details from a XML file with the following code:

$this->feedFile = file_get_contents(__ROOT__ . '/assets/feedList.xml'); //Define this externally
$this->feedDetailsArray = array();
$this->feedXML = new SimpleXMLElement($this->feedFile);
echo "1. =========";
print_r($this->feedXML);
echo "1. =========";
foreach($this->feedXML->Feed as $feedItem) {
    echo "2. =========";
    echo "AJ:: feedName " . var_dump($feedItem->FeedName) . " feedURL " . var_dump($feedItem->FeedURL) . "\n";
    echo "2. =========";
    $feedDetails = array(
        "feedName" => $feedItem->FeedName,
        "feedURL" => $feedItem->FeedURL/*,
        'favIconURL' => $feedItem->FavIconURL
        );
    echo "3. =========";
    var_dump($feedDetails);
    echo "3. =========";

The print_r outputs the following:

1. =========SimpleXMLElement Object
(
    [Feed] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [FeedName] => Hacker News
                    [FeedURL] => http://news.ycombinator.com/rss
                    [FavIconURL] => http://ycombinator.com/favicon.ico
                    [Segment] => Startups
                )

    .
    .
    .

The first var_dump (echo "feedName " . var_dump($feedItem->FeedName) . " feedURL " . var_dump($feedItem->FeedURL) . "\n";) outputs:

2. =========class SimpleXMLElement#38 (1) {
    string(11) "Hacker News"
}
class SimpleXMLElement#38 (1) {
    string(31) "http://news.ycombinator.com/rss"
}
AJ:: feedName  feedURL 
2. =========

And the 2nd var_dump outputs:

3. =========array(2) {
  'feedName' =>
  class SimpleXMLElement#38 (1) {
        string(11) "Hacker News"
  }
  'feedURL' =>
  class SimpleXMLElement#37 (1) {
        string(31) "http://news.ycombinator.com/rss"
  }
}
3. =========

My question is, why does the statement "feedName" => $feedItem->FeedName result in the object being assigned instead of the value of the SimpleXML object? I only want the value and not the object. Can someone please point out what I’m doing wrong?

  • 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-13T03:07:40+00:00Added an answer on June 13, 2026 at 3:07 am

    SimpleXML implements the __toString() magic method on its objects, which are otherwise assigned by object reference. When they are used in context of an echoed string (as one example), you’ll get the string value returned, but on a normal assignment or reference you’ll get the whole SimpleXMLElement object.

    If you want the string value, you can cast it to a string:

    $feedDetails = array(
        "feedName" => (string)$feedItem->FeedName,
        "feedURL" => (string)$feedItem->FeedURL
     );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
this is what i have right now Drawing an RSS feed into the php,
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.