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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:00:20+00:00 2026-05-13T16:00:20+00:00

I am using php xpath to get the values from the below xml feed

  • 0

I am using php xpath to get the values from the below xml feed and php the function.

<FOUND>
    <IMAGES>
    <IMAGE>
      <SMALL>images/small.jpg</SMALL> 
      <MED>images/med.jpg</MED> 
      <LARGE>images/large.jpg</LARGE> 
      <EXTRAL>images/extra.jpg</EXTRAL> 
    </IMAGE>
    <IMAGE>
      <SMALL>images1/small.jpg</SMALL> 
      <MED>images1/med.jpg </MED> 
      <LARGE>images1/large.jpg</LARGE> 
      <EXTRAL>images1/extra.jpg</EXTRAL> 
    </IMAGE>
    <IMAGE>
      <SMALL>images2/small.jpg</SMALL> 
      <MED>images2/med.jpg </MED> 
      <LARGE>images2/large.jpg</LARGE> 
      <EXTRAL>images2/extra.jpg</EXTRAL> 
    </IMAGES>
</FOUND>

function img ($id){

    $xml=simplexml_load_file("feed1.xml");
    //$xml=simplexml_load_string($string);
    if (!$xml) {
    trigger_error("There was an error",E_USER_ERROR);
    }

    $images=$xml->xpath('//IMAGE');
    return $images;

    }

above is only a partial code cz the feed is quite huge.. i would like to know is there are way to grab only the first and third block of image objects, skipping the 2nd block and display the remaining image blocks?

i have a separate huge xml feed which is quite similar to the above feed , its like 80 image object blocks .so i would like to display a message after each 10 blocks. how i do this?

any help will be much appreciated

  • 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-13T16:00:20+00:00Added an answer on May 13, 2026 at 4:00 pm

    To get the first and third block you can do:

    //IMAGE[position() == 1 || position() == 3]
    

    To get e.g. every 10th element you can do:

    //IMAGE[position() mod 10 == 0]
    

    See: XPath function reference.

    I am not quite sure what you exactly mean with display a message after each 10 block but you can do this:

    $images = $xml->xpath('//IMAGE');
    
    foreach($images as $key => $image) {
        // do whatever you want to do with the image 
        if($key % 10 == 9) {
            echo 'Some message';
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing XML results from an API call using PHP and xpath. $dom =
I am using php's simple xml and xpath to parse an rdf xml file
I am using the XPath in PHP 5 to parse a XML document. The
Hi Im trying to parse an xml feed using simplexml in php. The xml
I'm using this example to fetch links from a website : http://www.merchantos.com/makebeta/php/scraping-links-with-php/ $xpath =
I'm pulling data from an XML feed and manipulating it using the awesome SimpleXMLElement.
I need to get some part of html pages using php XPath query (sorry
Using PHP, is there a nice way to get the (parsed) introduction only from
I am trying to get the text from a page scrape using xpath, now
I am using a PHP function that will return 2 arrays. Below is my

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.