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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:42:49+00:00 2026-05-18T07:42:49+00:00

How? More to the point… this: $url = ‘http://php.net/manual/en/class.domelement.php’; $client = new Zend_Http_Client($url); $response

  • 0

How?

More to the point…

this:

$url = 'http://php.net/manual/en/class.domelement.php';
$client = new Zend_Http_Client($url);
$response = $client->request();
$html = $response->getBody();
$dom = new Zend_Dom_Query($html);
$result = $dom->query('div.note');
Zend_Debug::dump($result);

gives me this:

object(Zend_Dom_Query_Result)#867 (7) {
  ["_count":protected] => NULL
  ["_cssQuery":protected] => string(8) "div.note"
  ["_document":protected] => object(DOMDocument)#79 (0) {
  }
  ["_nodeList":protected] => object(DOMNodeList)#864 (0) {
  }
  ["_position":protected] => int(0)
  ["_xpath":protected] => NULL
  ["_xpathQuery":protected] => string(33) "//div[contains(@class, ' note ')]"
}

And I cannot for the life of me figure out how to do anything with this.

I want to extract the various parts of the retrieved data (that being the div with the class “note” and any of the elements inside it… like the text and urls) but cannot get anything working.

Someone pointed me to the DOMElement class over at php.net but when I try using some of the methods mentioned, I can’t get things to work. How would I grab a chunk of html from a page and go through it grabbing the various parts? How do I inspect this object I am getting back so I can at least figure out what is in it?

Hjälp?

  • 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-18T07:42:50+00:00Added an answer on May 18, 2026 at 7:42 am

    The Iterator implementation of Zend_Dom_Query_Result returns a DOMElement object for each iteration:

    foreach ($result as $element) {
        var_dump($element instanceof DOMElement); // always true
    }
    

    From the $element variable, you can use any DOMElement method:

    foreach ($result as $element) {
        echo 'Element Id: '.$element->getAttribute('id').PHP_EOL;
        if ($element->hasChildNodes()) {
            echo 'Element has child nodes'.PHP_EOL;
        }
        $aNodes = $element->getElementsByTagName('a');
        // etc
    }
    

    You can also access the document element, or you can use Zend_Dom_Query_Result to do so:

    $document1 = $element->ownerDocument;
    $document2 = $result->getDocument();
    var_dump($document1 === $document2); // true
    echo $document1->saveHTML();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime says that a session.cookie_lifetime of 0 goes until the browser is closed. Is
My knowledge of C++ at this point is more academic than anything else. In
More specifically I want to test whether Oracle ODP.Net is installed on a machine.
Is there anyway of configuring tomcat to point more than one context at a
This is actually comes from a specific WordPress issue but there's a more general
Edit -- I'll try to make my question more to the point I am
I want to use the conditional attribute on a class, or more to the
I wrote the following: public class Point { private double _radius , _alpha; public
1 The following is more to point out to the code devs an issue
i.e. will the blocking version return -1 on error. Or more to the point,

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.