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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:44:32+00:00 2026-05-28T14:44:32+00:00

I have a html structure like this.. <div id=divid> <ul id=ulid> <li style=margin-left: 8px>

  • 0

I have a html structure like this..

<div id="divid"> 
<ul id="ulid">
<li style="margin-left: 8px">
        <strong>books</strong>
</li>
<li style="margin-left: 6px">
        <a hre="">
        <span id="spanid">first line</span></a>
</li> 
<li style="margin-left: 6px">
        <a hre="">
        <span id="spanid">2nd line</span></a>
</li>
</ul>
</div>

i am parsing this html part and using xpath query

$xpath->query('//div[@id="divid"]/ul[@id="ulid"]/li/a');

and the output i want is

first line
2nd line

as for as i understand, my xpath query is okay if “strong” tag was not present in first “li” tag.

  • Note that first ‘li’ tag has strong tag while all other li tags have span tag in them
    now i want to EXCLUDED the ‘li’ tag (which consists ‘strong’ tag in it) from my xpath query so that i can get the values of tag below the anchor tag in li tag
    how can i modify the xpath query to make it possible? any guideline?

    the original code on which i was working was…

    <ul data-typeid="n" id="ref_1000">
    
         <li style="margin-left: -18px;">
                                                <a href="/s/ref=sr_ex_n_0?rh=i%3Aaps%2Ck%3Ahow+to+grow+tomatoes&amp;sort=salesrank&amp;keywords=how+to+grow+tomatoes&amp;ie=UTF8&amp;qid=1327692925">‹ <span class="expand">Any Department</span></a>
                                                </li>
                                        <li style="margin-left: 8px;">
                                                <strong>Books</strong>
                                            </li>
                                        <li style="margin-left: 6px;">
    
                                   <a href="/s/ref=sr_nr_n_0?rh=k%3Ahow+to+grow+tomatoes%2Cn%3A283155%2Cp_n_feature_browse-bin%3A618073011%2Cn%3A%211000%2Cn%3A48&amp;bbn=1000&amp;sort=salesrank&amp;keywords=how+to+grow+tomatoes&amp;ie=UTF8&amp;qid=1327692925&amp;rnid=1000">
                            <span class="refinementLink">Crafts, Hobbies &amp; Home</span><span class="narrowValue"> (19)</span>
                                    </a>
                        </li>
                <li style="margin-left: 6px;">
                                   <a href="/s/ref=sr_nr_n_1?rh=k%3Ahow+to+grow+tomatoes%2Cn%3A283155%2Cp_n_feature_browse-bin%3A618073011%2Cn%3A%211000%2Cn%3A10&amp;bbn=1000&amp;sort=salesrank&amp;keywords=how+to+grow+tomatoes&amp;ie=UTF8&amp;qid=1327692925&amp;rnid=1000">
                            <span class="refinementLink">Health, Fitness &amp; Dieting</span><span class="narrowValue"> (3)</span>
    
                                    </a>
                        </li>
                <li style="margin-left: 6px;">
                                   <a href="/s/ref=sr_nr_n_2?rh=k%3Ahow+to+grow+tomatoes%2Cn%3A283155%2Cp_n_feature_browse-bin%3A618073011%2Cn%3A%211000%2Cn%3A6&amp;bbn=1000&amp;sort=salesrank&amp;keywords=how+to+grow+tomatoes&amp;ie=UTF8&amp;qid=1327692925&amp;rnid=1000">
                            <span class="refinementLink">Cookbooks, Food &amp; Wine</span><span class="narrowValue"> (2)</span>
                                    </a>
                        </li>
    
                </ul>
    

    and i want to extract

    Crafts, Hobbies & Home etc closed in span tag

    • 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-28T14:44:33+00:00Added an answer on May 28, 2026 at 2:44 pm

      Taking the provided expression at face value — i.e. ignoring any contradictions between the expression and your description of it — you can use the following expression to exclude li elements that contain a strong child:

      //div[@id="divid"]/ul[@id="ulid"]/li[not(strong)]/a
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I have a html structure like this : <div id=nav_holder style=position:absolute;border-radius:400px;width:0px;height:0px;background-color:#460203;z-index:350px;> <div id=inner_wrap> </div>
    i have html structure like this <div> <span class=ic> <span class=ic>12345</span> </span> </div> i
    I currently have a HTML structure like this: <div id=holder> <div id=content>...</div> <div id=footer>...</div>
    Ok, so i have a HTML structure like this: <div class=content> <div id=a1 class=article>
    I have a nested ul menu structure that starts off like this: <div id=left>
    I have a html structure like this: <div class=one> <div id=two> <h2>Any</h2> <h4>Any</h4> </div>
    I have a structure of html like this: <div id="triger1">some elements inside</div> <div id="triger2">some
    I have one html structure , somethinh like <div> <div id=mydiv> <h3> This is
    let's say I have an HTML structure like this: <div class=first> <div class=sub-1> <div
    I have a html structure like : <div onmouseover=enable_dropdown(1); onmouseout=disable_dropdown(1);> My Groups <a href=#>(view

    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.