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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:55:54+00:00 2026-05-16T14:55:54+00:00

test.html <html> <body> <span> hello Joe</span> <span> hello Bob</span> <span> hello Gundam</span> <span> hello

  • 0

test.html

<html>
    <body>
        <span> hello Joe</span>
        <span> hello Bob</span>
        <span> hello Gundam</span>
        <span> hello Corn</span>
    </body>
</html>

PHP file

$doc = new DOMDocument();
$doc->loadHTMLFile("test.html");

$xpath = new DOMXPath($doc);

$retrieve_data = $xpath->evaluate("//span");

echo $retrieve_data->item(1);
var_dump($retrieve_data->item(1));
var_dump($retrieve_data);

I am trying to use xPath to find the spans and then echo it, but it seems I cannot echo it. I tried dumping it to see if is evaluating properly, and I am not sure what does this output mean:

object(DOMElement)#4 (0) { } 
object(DOMNodeList)#7 (0) { }

What does the #4 and #7 mean and what does the parenthesis mean; What is does the syntax mean?

Update:
This is the error I get when I try to echo $retrieve_data; and $retrieve_data->item(1);

Catchable fatal error: Object of class DOMNodeList could not be converted to string
  • 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-16T14:55:54+00:00Added an answer on May 16, 2026 at 2:55 pm

    If you want to output text inside span you can use textContent property:

    echo $retrieve_data->item(1)->textContent;

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

Sidebar

Related Questions

The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span>
HTML <body> <span>test</span> <span>test</span> <span>test</span> <span id=show>aaaaaa</span> </body> JS $('body').hide(); $('#show').show(); Why doesn't this
I have code like this: string uriString = @C:\Temp\test.html; Uri uri = new Uri(uriString);
So I have been experimenting with building a new site... http://zergxost.com/test.html - it will
I'm trying to parse an html file. The idea is to fetch the span's
Take the following markup: <!DOCTYPE html> <html> <head> <title>My test for StackOverflow</title> </head> <body>
This is the HTML I have: p_tags = '''<p class=foo-body> <font class=test-proof>Full name</font> Foobar<br
Suppose we have the following HTML file: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Test iframe download</title> <script
I am using Valum's fileuploader http://valums.com/ajax-upload/ The below index.html uploads a file, and post.php

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.