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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:34:58+00:00 2026-06-15T16:34:58+00:00

writing this: $likes = $xpath->query(‘//span[@class=LikesCount]’); this is waht I get: 155 like I would

  • 0

writing this:

$likes = $xpath->query('//span[@class="LikesCount"]');

this is waht I get:

155 like

I would like to write the query so that number_before_like > 5

$likes = $xpath->query('

((int)substring-before(//span[@class="LikesCount"], " ")) > 5


');

Follows the markup:

<div class="pin">

[...]

<a href="/pin/56787645270909880/" class="PinImage ImgLink">
    <img src="http://media-cache-ec3.pinterest.com/upload/56787645270909880_d7AaHYHA_b.jpg" alt="Krizia" data-componenttype="MODAL_PIN" class="PinImageImg" style="height: 288px;">
</a>

<p class="stats colorless">
    <span class="LikesCount"> 
        2 likes 
    </span>
    <span class="RepinsCount">
        6 repins
    </span>
</p>

[...]

</div>
  • 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-15T16:35:00+00:00Added an answer on June 15, 2026 at 4:35 pm

    You can do this with XPath syntax alone, by making sure that extraneous whitespace is taken out of the picture.

    $query = 'number(substring-before(normalize-space(
              //span[@class="LikesCount" 
              and substring-before(normalize-space(.), " ") > 5]), " "))';
    
    $likes = $xpath->evaluate($query);
    

    Alternatively, let PHP do the hard work for you.

    $query = 'number(php:functionString("intval",
              //span[@class="LikesCount"
              and php:functionString("intval", .) > 5]))';
    
    $xpath->registerNamespace('php', 'http://php.net/xpath');
    $xpath->registerPHPFunctions("intval");
    $likes = $xpath->evaluate($query);
    

    If you’re going to start asking PHP to do some of the work, it might well just be easier to use a simple query and filter the results as you need.

    foreach ($xpath->query('//span[@class="LikesCount"]') as $span) {
        $int = (int) $span->nodeValue;
        if ($int > 5) {
            echo $int;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was writing a metaclass and accidentally did it like this: class MetaCls(type): def
Suppose I have a query like this: SELECT t1.name, t2.likes FROM table_1 t1 LEFT
I feel like I am not writing this correctly and this is my first
What is a good way of writing something like this in one line. The
I'm not going to use other module like request , how about writing this
I am writing a function like this. func :: IO() func = putStr print
I'm writing some code that looks like this: while(true) { switch(msg->state) { case MSGTYPE:
I am writing a logger for a sorting function like this: bubble :: (Ord
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
Often when writing PHP I'll have it output some HTML like this - echo

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.