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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:04:53+00:00 2026-06-02T15:04:53+00:00

I have following HTML which I am trying to read from the DOMNodeList when

  • 0

I have following HTML which I am trying to read from the DOMNodeList when I query a HTML document with xPath in PHP code. This is my query $description = $xpath->query("//div[@class='qsc-html-content']");

I expect that I shall be able to fetch every thing inside 2nd div. Im new to xPath in PHP. The problem is when I try anything like following :

        if(isset($description) && is_object($description)){
        echo "DESCIPTION SET";
        echo $description->tagName;

        //echo $description->getElementsByTagName("p");
        $productInfo['description'] = trim($description->nodeValue);            
    }

I do not get any result.

<div class="product-description ">
<div class="qsc-html-content">
    <p><span class="Apple-style-span" style="background-color: #ffffff; font-family: Verdana, sans-serif;">Farida is a new and upcoming brand in the hookah market which specializes in solid brass hookahs. The designs are very unique and have not been seen in the hookah industry before. </span>This hookah stand about&nbsp;36".</p>
    <ul>
    <li>Farida&nbsp;hose</li>
    <li>Tongs, Grommets, Bowl, &amp; Farida Gold Tray</li>
    </ul>
    <p><span style="color: #ff0000;"><strong><span style="font-size: x-small;">Please Not: </span></strong></span></p>
    <p>&nbsp;Glass bases are mouth blown and sometimes have air bubbles as evidence of this fact. <span style="font-size: xx-small;">Artisans hand paint each glass base, making every one as unique as the artist. This results in a 100% unique finished product that may not look identical to the photo. It also means that sometimes the paint may have a slight smudge, a line may not be perfectly straight, or you may see the artist's brush strokes.</span></p>
    <p>Egyptian products are handmade in a traditional manner. Because these hookahs are handmade, there are usually slight variations from hookah to hookah. Most hookahs contain visible weld lines or unpolished metal at the welds.</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #ff0000;">FREE STARTER KIT INCLUDES:</span> 1 Holland Charcoal, 10 Mouth Tips, and 2 AL Fakher 50g Tobbacos Select Flavors</p>
    <p><img alt="" height="55" src="media/round tablets.jpg" width="103" />&nbsp;&nbsp;&nbsp;<img alt="" height="81" src="media/male_mouth_tips.jpg" width="109" /> <img alt="" height="86" src="media/d_al_fakher_50g.jpg" width="126" />&nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>

Some one can please guide me where I am wrong. There is another problem where I am trying to fetch list of anchor tags by xPath query and the result is returning only singe anchor.

I had banged my head onto this for last 2 hours. I am exhausted now.

thanks

  • 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-02T15:04:55+00:00Added an answer on June 2, 2026 at 3:04 pm

    The result from $xpath->query(...) is a DOMNodeList object. It’s not a single element, so using:

    echo $description->tagName;
    

    is wrong. Instead you should iterate the result, like this:

    $description = $xpath->query("//div[@class='qsc-html-content']");
    foreach ($description as $item) {
        echo $item->tagName . "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header.html which start with session_start();. Then the following code, $_SESSION['cart'][$sw_id] is
I have the following code which loads and html file into a webview -
I have the following code which creates a new table. var html = '<table>';
I have the following html code, and I am trying to get all the
I have the following snippet which I am trying to output the html of
I have the following line of code in my program which I took from
I have the following html structure (which is generated and I can't change): <table
I have the following messy HTML table which is being used to present a
i have the following html , and i want to hide all lsHeader which
I have a thttpd server set-up which has the following html file. When I

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.