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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:02:55+00:00 2026-06-01T07:02:55+00:00

I’m trying to get some data from a table, where the tag has no

  • 0

I’m trying to get some data from a table, where the tag has no id, class or any other attribute that can identify it.

The table structure is something like this:

<table>
<tr>
    <td><b>Type</b></td>
    <td>Plug and Play</td>
</tr>
<tr>
    <td><b>Model</b></td>
    <td>AH591Z</td>
</tr>
<tr>
    <td><b>Date</b></td>
    <td>02.04.2012</td>
</tr>
<tr>
    <td><b>Name</b></td>
    <td>CryptMachine</td>
</tr>
<tr>
    <td><b>ID</b></td>
    <td>9283</td>
</tr>
</table>

How would I for example get the Model, Name and ID but ignore the date and type, because I don’t need those values.

Is there a smart way to do this with phpQuery? So far I’ve just played around with the phpQuery library, but i definitely got the basics down, I just cannot wrap my brain around this.

  • 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-01T07:02:57+00:00Added an answer on June 1, 2026 at 7:02 am

    I haven’t tested this, but something like this maybe?

    $doc = phpQuery::newDocumentHTML($theDocument);
    $table = $doc["table"];
    $model = pq($table)->find("tr:eq(1) td:eq(1)")->text();
    $id = pg($table)->find("tr:eq(4) td:eq(1)")->text();
    

    If there is more than one table on the page, you may have to use eq(n) to specify which one, remember that they are enumerated from 0, not 1.

    UPDATE: If you don’t know the order of the rows, you could use something like this (again, untested, sorry, but should get your pointed in the right direction)

    <?php
    
    function getValue($table, $label) {
        $lable = strtolower($label);
        $rows = pq('tr', $table);
    
        foreach($rows as $row):
            if ( strtolower(pq($row)->find('td:eq(0)').text() ) === $label ):
                return pq($row)->find('td:eq(1)').text();
            endif;
        endforeach;
    }
    
    $doc = phpQuery::newDocumentHTML($theDocument);
    $table = $doc["table"];
    
    $model = getValue($table, "Model");
    $id = getValue($table, "ID");
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post

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.