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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:29:55+00:00 2026-06-05T18:29:55+00:00

Possible Duplicate: Selecting a css class with xpath I am trying to extract the

  • 0

Possible Duplicate:
Selecting a css class with xpath

I am trying to extract the source for all images inside a html like this

    <li class="carousel_item">
    <img src="http://www.xxxx.com/1fc1c1c2db5852e08ffcff38.jpg" 
                        width="200" 
                        height="200" 

                        style="margin-bottom:1px" 
                        class="image_error" /> 
                    <span class="image_error" title="jpg"></span> 
                    <span class="image_error" title="2.jpg"></span> 
                </li> 

When I use the following commands I get all images in the document

   $nodelist = $xpath->query( "//img/@src" );
   foreach ($nodelist as $n){
    echo  $n->nodeValue."<br>";
 }

but I want just the items listed in the class=”carousel_item”

Is this possible?

  • 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-05T18:29:56+00:00Added an answer on June 5, 2026 at 6:29 pm

    Sure, just include the <li> and its class attribute in the query. You just need to change the xpath string to:

    $nodelist = $xpath->query( "//li[@class='carousel_item']/img/@src" );
    

    Demo

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

Sidebar

Related Questions

Possible Duplicate: select all checkboxes command jquery, javascript I am having trouble selecting all
Possible Duplicate: Is there a CSS parent selector? Hi! I'm trying to select a
Possible Duplicate: How to implement “select all” check box in HTML? Select all and
Possible Duplicate: selecting items that come after a specific value i asked this allready
Possible Duplicate: Selecting data from two different servers in SQL Server How can I
Possible Duplicate: Get selected element's outer HTML I want to alert the html of
Possible Duplicate: What does “>” mean in CSS rules? CSS has the following two
Possible Duplicate: Selecting a JSON object with a colon in the key I apologize
Possible Duplicate: Change language programatically in Android I would like to develop an Android
Possible Duplicate: Selecting a row in Datagridview Programatically? I am developing a new desktop

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.