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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:55:18+00:00 2026-06-11T23:55:18+00:00

this the html page: <div class=gs_ri> <h3 class=gs_rt> <span class=gs_ctc> <span class=gs_ct1>[BOOK]</span> <span class=gs_ct2>[B]</span></span>

  • 0

this the html page:

<div class="gs_ri">
   <h3 class="gs_rt">
     <span class="gs_ctc">
     <span class="gs_ct1">[BOOK]</span>
     <span class="gs_ct2">[B]</span></span>
     <a href="http://example.com" onmousedown="">Title</a></h3>
<div class="gs_a">A</div>
<div class="gs_rs">B</div>
<div class="gs_fl"><a href="">C</a> <a href="">D</a> <a href=""</a></div></div></div>  
<div class="gs_r"><div class="gs_ggs gs_fl"><button type="button" id="gs_ggsB2" class="gs_btnFI gs_in_ib gs_btn_half">
     <span class="gs_wr"><span class="gs_bg"></span>
     <span class="gs_lbl"></span>
     <span class="gs_ico"></span></span></button>
<div class="gs_md_wp" id="gs_ggsW2"><a href="http://example.pdf" onmousedown=""

I’m a little confused to determine the node.

I wanna get http://example.com and Title

I thought there are 2 ways to get them:

it’s a sibling of the <span>:

 foreach($html->find('span[class=gs_ctc2] ') as $link){
    $link = $link->next_sibling();
    echo $link->plaintext;
    echo $link->href;
}

but it does not work.

the second, I take <h3 class="gs_rt"> as parent, so it’s the sibling of last child

foreach($html->find('h3[class=gs_rt] a') as $link){
    $link = $link->last_child()->next_sibling();
    echo $link->plaintext;
    echo $link->href;
}

it also does not work. I think that I am not understanding yet abot node dom tree.

  • 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-11T23:55:19+00:00Added an answer on June 11, 2026 at 11:55 pm

    You do not have to select a sibling.

    With h3[class=gs_rt] a you are already targeting the respective <a> tag. So just extract the desired values from there. You can, however, simplify that selector as follows:

    foreach($html->find('h3.gs_rt a') as $link){
        echo $link->plaintext;
        echo $link->href;
    }
    

    EDIT

    With regard to the comment, I think, what you want is something like this, but I’m not sure and your code above is quite a mess (please use proper indention!)

    foreach($html->find('h3.gs_rt') as $block){
        $link = $block->find( 'a' );
        echo $link->plaintext;
        echo $link->href;
    
        $otherLink = $block->find( 'div[class=gs_md_wp] a' );
        // do stuff with that $otherLink
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

imagine this html on a page <div id=hpl_content_wrap> <p class=foobar>this is one word and
I have simple HTML page with svg like this: <div id=plan> <svg xmlns=http://www.w3.org/2000/svg version=1.1>
I wanna get the title and link from this html page : <div class=gs_r>
I'd like my buttons to look like this in HTML: <a href=page.html class=button>Link</a> And
In this html I basically have a sidebar-div and a page-div with the header,
I have this HTML in my page <div id='masterDIV'> <div id='divItemNumber'>23</div> <div id='divDesc'>This is
I have an HTML page that roughly looks like this: <div id=rolesRollerBody style=height: 309px;>
The main structure of the page is like this: <html> <body> <div id=Menu> <h1>Menu</h1>
I have the following XPath to match authors name in an Amazon page: //div[@class='pTitle']/span[@class='small
I have a html page that contains a structure like this: <table class=pick> <tr>

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.