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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:52:25+00:00 2026-05-29T08:52:25+00:00

How do I get all the TITLE and LINKS reading from a file ?

  • 0

How do I get all the TITLE and LINKS reading from a file ?

A sample content of the file below

<tr class="odd">
 <td align="left" valign="top" class="text_cont_normal"> TITLE </td>
 <td align="left" valign="top" class="normal_text_link">
  <img border="0" onclick="javascript:window.location.href='LINK'" style="cursor: pointer;" alt="Download"  src="btn.jpg"/></td>
</tr>
<tr class="even">
 <td align="left" valign="top" class="text_cont_normal"> TITLE2 </td>
 <td align="left" valign="top" class="normal_text_link">
  <img border="0" onclick="javascript:window.location.href='LINK2'" style="cursor: pointer;" alt="Download"  src="btn.jpg"/></td>
</tr>

I tried

$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
 if ($tag->hasAttribute('onclick'))
    echo $tag->getAttribute('onclick').'<br>';
}

But not getting the data which I actually want !

  • 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-29T08:52:27+00:00Added an answer on May 29, 2026 at 8:52 am

    Like this, for example

    $doc = new DOMDocument();
    $doc->loadHTMLFile($filename);
    $xpath = new DOMXPath($doc);
    $nodes = $xpath->query('//td[@class="text_cont_normal"]');
     foreach($nodes as $node)
     {
        echo $node->nodeValue.'<br>';   // title
     }
    $nodes = $xpath->query('//td[@class="normal_text_link"]/img[@alt="Download"]');
     foreach($nodes as $node)
     {
      if ($node->hasAttribute('onclick'))
         echo $node->getAttribute('onclick').'<br>';  //click
     }
    

    If you need exactly the LINK then rewrite

      if ($node->hasAttribute('onclick'))
      {
          echo $node->getAttribute('onclick').'<br>';  //click
          preg_match('/location\.href=(\'|")(.*?)\\1/i', 
                     $node->getAttribute('onclick'), $matches);
          if (isset($matches[2])) echo $matches[2].'<br>'; // the value
      }
    

    Or do you need them in groups?

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

Sidebar

Related Questions

Im trying to first grab all the links from a page, when get the
Title pretty much describes it, I just need to get all the order numbers
I try to generate title in all levels of the officers but I get
I'm having an issue here, I am trying to get all the titles from
I am trying to get all Books from the server (local PHP script), that
I'm trying to get all downloads from an repo on github with help of
How can i get all child nodes from sql table? (MemberJoiners table on pict)
I am looping through a list of links. I can correctly get the title
Im trying to change title style for all links however i just found how
so I get error when I use bgstretcher, all links are correct to scripts,

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.