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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:20:03+00:00 2026-06-16T00:20:03+00:00

i am new to DOM Document.. i have this html: <tr class=calendar_row data-eventid=39657> <td

  • 0

i am new to DOM Document..
i have this html:

    <tr class="calendar_row" data-eventid="39657">
        <td class="alt1 eventDate smallfont" align="center">Sun<div class="eventday_multiple">Dec 9</div></td>
        <td class="alt1 smallfont" align="center">3:34am</td>
        <td class="alt1 smallfont" align="center">USD</td>
    </tr>

    <tr class="calendar_row" data-eventid="39658">
        <td class="alt1 eventDate smallfont" align="center">Sun<div class="eventday_multiple">Dec 10</div></td>
        <td class="alt1 smallfont" align="center">5:14am</td>
        <td class="alt1 smallfont" align="center">EUR</td>
    </tr>

i am trying to get first the contents inside the tr’s using this code:

    $ret = array();
    libxml_use_internal_errors(true); 
    $doc = new DOMDocument();
    $doc->loadHTML($html);
    //$doc->saveHTMLFile('textbox.php');

    $text = $doc->getElementsByTagName('tr');
    foreach ($text as $tag){
        $ret[] = $doc->saveHtml($tag); 
        echo $doc->saveHtml($tag); 
    }

i dont know why the value being echoed was the whole document and not the values inside the tr’s..

second, i would like also to get the values in between those td tags like 5:14 AM,EUR,etc. but i dont have any idea how to do that.

Pardon for noob question..

Best Regards

  • 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-16T00:20:04+00:00Added an answer on June 16, 2026 at 12:20 am
    $doc = new DOMDocument();
    $doc ->loadHTML("$html");
    $tables = $doc->getElementsByTagName('table');
    $table = $tables->item(0);//takes the first table in dom
    
    foreach ($table->childNodes as $td) {
      if ($td->nodeName == 'td') {
        echo $td->nodeValue, "\n";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this kind of HTML document. <span class=class1>text1</span> <a href=>link1</a> <font color=><b>text2</b></font> <a
I'm new to DOM parsing in PHP: I have a HTML file that I'm
I have a HTML document (string) which contains a div with the class foo:
i have table like <html> <body> <table id=data class=outer> <tr><td>Date</td><td>12-09-12</td></tr> <tr><td>Price</td><td>15.00</td></tr> <tr><td>Count</td><td>67</td></tr> </table> </body>
I have this code: $reader = new DOMDocument(); $reader->loadHTML($shell); $xpath = new DomXPath($reader); $xpath->registerNamespace('html','http://www.w3.org/1999/xhtml');
So I have this code inside of a class file: Document requestData (String url,
I have this simple project to grab HTML element inner data. This is a
Hi i have a code like this: $doc = new DOMDocument(); $doc->Load('courses.xml'); foreach ($doc->getElementsByTagName('courses')
After inserting new html to DOM,I need to add some listeners to it. But
Here is example which I have try <?php include 'spider/classes/simple_html_dom.php'; $html = new simple_html_dom();

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.