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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:13:59+00:00 2026-05-31T05:13:59+00:00

I have a table such this : <table> <tr> <td>Values</td> <td>5000</td> <td>6000</td> </tr> </table>

  • 0

I have a table such this :

<table>
<tr>
    <td>Values</td>
    <td>5000</td>
    <td>6000</td>
</tr>
</table>

And I want to get td’s content. But I could not manage it.

<?PHP
$dom = new DOMDocument();
$dom->loadHTML("figures.html"); 
$table = $dom->getElementsByTagName('table');
$tds=$table->getElementsByTagName('td');

foreach ($tds as $t){
   echo $t->nodeValue, "\n";
}
?>
  • 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-31T05:14:00+00:00Added an answer on May 31, 2026 at 5:14 am

    There are multiple problems with this code:

    1. To load from an HTML file, you need to use DOMDocument::loadHTMLFile(), not loadHTML() as you have done. Use $dom->loadHTMLFile("figures.html").
    2. You can’t use getElementsByTagName() on a DOMNodeList as you have done (on $table). It can only be used on a DOMDocument.

    You could do something like this:

    $dom = new DOMDocument();
    $dom->loadHTMLFile("figures.html");
    $tables = $dom->getElementsByTagName('table');
    
    // Find the correct <table> element you want, and store it in $table
    // ...
    
    // Assume you want the first table
    $table = $tables->item(0);
    
    foreach ($table->childNodes as $td) {
      if ($td->nodeName == 'td') {
        echo $td->nodeValue, "\n";
      }
    }
    

    Alternatively, you could just directly search for all elements with tag name td (though I’m sure you want to do that in a table-specific manner.

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

Sidebar

Related Questions

I have a table of values like this: http://www.conversiontable.org/clothingsizeconversiontable.html and I want to declare
I currently have a table in MySQL that stores values normally, but I want
I have some problem whith such mysql_query INSERT INTO table VALUES ('', CURDATE()-1) why
If I have two tables such as this: CREATE TABLE #table1 (id INT, name
I have a table column that contains values such as abc_1_2_3_4.gif or zzz_12_3_3_45.gif etc.
I have table with 50 entries (users with such details like Name Surname Location
Lets say I have a table with columns such as: ID Name City State
i have a table with the columns such id, tid, companyid, ttype etc.. the
I have a contacts table which contains fields such as postcode , first name
If I have a simple table where the data is such that the rows

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.