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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:27:27+00:00 2026-06-17T09:27:27+00:00

I have an rss feed that is formatted something like this: <item> <posturl>mysite.com/abc.html</posturl> <imagepath>123.jpg</imagepath>

  • 0

I have an rss feed that is formatted something like this:

<item>
     <posturl>mysite.com/abc.html</posturl>
     <imagepath>123.jpg</imagepath>
</item>
<item>
     <posturl>mysite.com/def.html</posturl>
     <imagepath>456.jpg</imagepath>        
</item>
<item>
     <posturl>mysite.com/ghi.html</posturl>
     <imagepath>789.jpg</imagepath>    
</item>

I have a script where I want to extract both the values above. I can extract one of the values and build html code using code like:

<?php
     $xml = simplexml_load_file('http://myrssfeed.com');
     $imgs = $xml->xpath('//imagepath');
            echo '<ul>';
         foreach($imgs as $output1) {
            echo '<li><img src="' . $output1 . '" ></li>';
            }

            echo '</ul>';
 ?>

This works like a charm thanks to all the help from people here. But I need to expand that second echo line to read something like:

echo  '<li><a href="' . $output2 . '"><img src="' . $output1 . '" ></a></li>';

I need help on how to extract $output2 = posturl within the same item as $output1.

Basically I need to display the images as links… both imagepath and posturl are elements within item.

Many thanks.

  • 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-17T09:27:28+00:00Added an answer on June 17, 2026 at 9:27 am

    You could select the <item> elements instead of <posturl> and <imagepath>. Like this:

    $xml = simplexml_load_file('http://myrssfeed.com');
    
    echo '<ul>';
    
    foreach($xml->xpath('//item') as $item) { 
        printf('<li><a href="%s"><img src="%s" /></a></li>', 
            $item->posturl, $item->imagepath); 
    }
    
    echo '</ul>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that has an Rss feed, and this feed is consumed
I have an Rss feed that I have parsed in one activity. Each item
I have an RSS feed from Zendesk (http://mysupport.zendesk.com/forums/some-path/posts.rss) that I need to render as
i have this rss feed to parse that contains several tags. i am able
I have an RSS feed that I follow and would like to display it
I have an rss feed that spits out plain html so I want to
I have two websites that declare an RSS feed, like so: <link rel=alternate type=application/rss+xml
I have previsously parsed this RSS Feed, now that I have updated it to
I have a dynamically generated rss feed that is about 150M in size (don't
I have an RSS feed and I want to integrate each item into it

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.