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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:25:48+00:00 2026-06-18T08:25:48+00:00

I am trying to retrieve certain values using php xpath evaluate or query. But

  • 0

I am trying to retrieve certain values using php xpath evaluate or query. But not able to do it successfully.
Here is the html structure of the page:

<div id="productinfo">
<h2>
<span id="productname">Computer</span>
</h2>
<span id="servieidLabel" style=""> Service ID: </span>
<span id="snLabel" style="display: none"> Serial Number: </span>
<span id="servidno">12345ABCD</span>

I want to display only contents with style=”display:none” or if style attribute is not there at all. So that the result is:- Service ID: 12345ABCD.

I have tried:

$ServLab = $xpath->query("//span[@id='servieidLabel']");
foreach ($ServLab as $entry) {
echo "Service Label:" ,$entry->nodeValue."<br />";
}

Output= Service ID:

and

$servid = $xpath->query("//span[@id='servidno']");
foreach ($servid as $entry) {
echo "Service Id No:" ,$entry->nodeValue."<br />";
}

Output = blank. Whereas the output is supposed to 12345ABCD. What am I missing?

If I try:

$prodid = $xpath->evaluate("//div[@id='productinfo']");
foreach ($prodid as $entry) {
echo $entry->nodeValue."<br />";
}

Output = Service ID: Serial Number:

Please help.

  • 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-18T08:25:49+00:00Added an answer on June 18, 2026 at 8:25 am

    The question you stated first could be solved in a single query. Like this one:

    $ServLab = $xpath->query("//div/span[string-length(@style) < 1]");
    foreach ($ServLab as $entry) {
        echo $entry->nodeValue."<br />";
    }
    

    This will provide

    Service ID: 
    12345ABCD
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to retrieve RSS feed using php. The xml has many different
I'm trying to retrieve email using IMAP that's less than a certain number of
As the header is implying I'm trying to retrieve a certain line of numbers
I'm trying to retrieve this page using Apache HttpClient: http://quick-dish.tablespoon.com/ Unfortunately, when I try
Hi I am trying to retrieve values from database. I have a row which
I am trying to retrieve the curent users UserId from the membership provider but
Im trying to download and synchronize imap email but when I download certain messages
I am trying to retrieve certain fields within a .lua file. Initially I thought
I am trying to do an SQL query on two tables to retrieve multiple

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.