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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:26:56+00:00 2026-05-14T05:26:56+00:00

My code does not pull the proper link for the item. Instead it’s getting

  • 0

My code does not pull the proper link for the item. Instead it’s getting the previous item’s link.

Any suggestions? Thanks!

<?php
// Load the XML data from the specified file name.  
// The second argument (NULL) allows us to specify additional libxml parameters,
// we don't need this so we'll leave it as NULL.  The third argument however is
// important as it informs simplexml to handle the first parameter as a file name
// rather than a XML formatted string.
$pFile = new SimpleXMLElement("http://example.blogspot.com/feeds/posts/default?alt=rss", null, true);  

// Now that we've loaded our XML file we can begin to parse it.
// We know that a channel element should be available within the,
// document so we begin by looping through each channel
foreach ($pFile->channel as $pChild)
{    

    // Now we want to loop through the items inside this channel
    {

    foreach ($pFile->channel->item as $pItem)
    {

        // If this item has child nodes as it should, 
        // loop through them and print out the data


        foreach ($pItem->children() as $pChild)
        { 
            // We can check the name of this node using the getName() method.
            // We can then use this information, to, for example, embolden
            // the title or format a link
            switch ($pChild->getName())
            {
                case 'pubDate':
                    $date = date('l, F d, Y', strtotime($pChild));
                    echo "<p class=\"blog_time\">$date</p>"; 
                    break;

                case 'link':
                    $link = $pChild;
                    break;

                case 'title':

                    echo "<p class=\"blog_title\"><a href=\"$link\">$pChild</a></p>";
                    break;

               case 'description':
                    // echo substr(strip_tags($pChild), 0 , 270) . "...";
                    break;



                case 'author':
                    echo "";
                    break;    
                case 'category':
                    echo "";
                    break;
                case 'guid':
                    echo "";
                    break;

                default:
                    // echo strip_tags($pChild) . "<br />\n";
                    break;
            }

        }

   }


   }

}

?> 
  • 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-14T05:26:56+00:00Added an answer on May 14, 2026 at 5:26 am

    Maybe I’ll say something stupid (maybe I quite don’t understand what you’re trying to do ?), but would something like this not be OK :

    $pFile = new SimpleXMLElement("http://example.blogspot.com/feeds/posts/default?alt=rss", null, true);  
    foreach ($pFile->channel->item as $item) {
        echo "date : " . (string)$item->pubDate . '<br />';
        echo "title : " . (string)$item->title . '<br />';
        echo "URL : " . (string)$item->link . '<br />';
        echo '<hr />';
    }
    

    Basically, one you have loaded the XML data, you can iterate over its content : it has a simple object/array structure.

    Don’t hesitate to take a look at the output of var_dump($pFile);, to see how it looks like 😉

    And this portion of code would display some output like this :

    date : Sun, 06 Feb 2005 13:39:00 +0000
    title : ROSHAN & 2ND IN COMMAND, WOULD LIKE TO THANK THE FOLLOWING PEOPLE, FOR UNITING WITH US FOR THE PEOPLE OF SRI LANKA. MAY GOD BLESS YOU ALL!
    URL : http://example.blogspot.com/2005/02/roshan-2nd-in-command-would-like-to.html
    ======
    date : Sat, 05 Feb 2005 23:26:00 +0000
    title : ROSHAN & 2ND IN COMMAND, UNITED!, FOR THE PEOPLE OF SRI LANKA, JOIN US!
    URL : http://example.blogspot.com/2005/02/roshan-2nd-in-command-united-for.html
    ======
    date : Sat, 05 Feb 2005 23:01:00 +0000
    title : 2ND IN COMMAND!, A HOT EMERGING NEW ARTIST!
    URL : http://example.blogspot.com/2005/02/2nd-in-command-hot-emerging-new-artist.html
    ======
    date : Sat, 05 Feb 2005 22:43:00 +0000
    title : ICP (IN COMMAND PRODUCTIONS), Hip-Hop R&B Music & much much more!, UNITED!, FOR THE PEOPLE OF SRI LANKA
    URL : http://example.blogspot.com/2005/02/icp-in-command-productions-hip-hop-rb.html
    ======
    

    Well, you’ll have to adapt this a bit, if you want to display HTML tags, but this should at least help you getting started…

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

Sidebar

Ask A Question

Stats

  • Questions 354k
  • Answers 354k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer [NSUserDefaults standardUserDefaults] is the approach to take if there is… May 14, 2026 at 8:21 am
  • Editorial Team
    Editorial Team added an answer Depends on how big those functions are. If your source… May 14, 2026 at 8:21 am
  • Editorial Team
    Editorial Team added an answer The right sintax should be something like this: !blue =… May 14, 2026 at 8:21 am

Related Questions

I'm a user of Aquamacs under OS X, which by default does not recognize
My apologies if this is a duplicate; I may not know the proper terms
I have a Powershell script that is loading a .NET assembly (.EXE in my
I have a table with many values inside of it that might have single
I'm trying to follow the custom module tutorial at http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/modules-and-namespaces/creating-your-own-modul I've got a local

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.