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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:16:29+00:00 2026-05-14T21:16:29+00:00

can anybody help/advice that is there any way to parse HTML tags appear in

  • 0

can anybody help/advice that is there any way to parse HTML tags appear in side the <body>...</body> tags

  • 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-14T21:16:30+00:00Added an answer on May 14, 2026 at 9:16 pm

    I suppose you want to parse a HTML document using PHP. I suggest you read about the http://www.php.net/manual/en/book.dom.php

    Here is an example provided by PHP Pro

    <?php
    
    $html = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" dir="ltr">
    <head>
    <title>PHPRO.ORG</title>
    </head>
    <body>
    <h2>Forecast for Saturday</h2>
    <!-- Issued at 0828 UTC Friday 23 May 2008 -->
    <table border="0" summary="Capital Cities Precis Forecast">
       <tbody>
          <tr>
             <td><a href="/products/IDN10064.shtml" title="Link to Sydney forecast">Sydney</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">19&deg;</td>
             <td>Fine. Mostly sunny.</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDV10450.shtml" title="Link to Melbourne forecast">Melbourne</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">16&deg;</td>
             <td>Fog then fine.</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDQ10095.shtml" title="Link to Brisbane forecast">Brisbane</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">24&deg;</td>
             <td>Mostly fine</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDW12300.shtml" title="Link to Perth forecast">Perth</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">21&deg;</td>
             <td>Few showers, increasing later.</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDS10034.shtml" title="Link to Adelaide forecast">Adelaide</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">20&deg;</td>
             <td>Fine. Mostly sunny.</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDT65061.shtml" title="Link to Hobart forecast">Hobart</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">13&deg;</td>
             <td>Mainly fine.</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDN10035.shtml" title="Link to Canberra forecast">Canberra</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">15&deg;</td>
             <td>Fine, mostly sunny.</td>
          </tr>
    
          <tr>
             <td><a href="/products/IDD10150.shtml" title="Link to Darwin forecast">Darwin</a></td>
             <td title="Maximum temperature in degrees Celsius" class="max alignright">32&deg;</td>
             <td>Fine and sunny.</td>
          </tr>
    
       </tbody>
    </table>
    
    </body>
    </html>
    ';
    
        /*** a new dom object ***/
        $dom = new domDocument;
    
        /*** load the html into the object ***/
        $dom->loadHTML($html);
    
        /*** discard white space ***/
        $dom->preserveWhiteSpace = false;
    
        /*** the table by its tag name ***/
        $tables = $dom->getElementsByTagName('table');
    
        /*** get all rows from the table ***/
        $rows = $tables->item(0)->getElementsByTagName('tr');
    
        /*** loop over the table rows ***/
        foreach ($rows as $row)
        {
            /*** get each column by tag name ***/
            $cols = $row->getElementsByTagName('td');
            /*** echo the values ***/
            echo $cols->item(0)->nodeValue.'<br />';
            echo $cols->item(1)->nodeValue.'<br />';
            echo $cols->item(2)->nodeValue;
            echo '<hr />';
        }
    ?> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody help me in finding out how to verify that _tmkdir succeeded. For
can anybody help me to call a server side javascript method from the client
Can anybody advice some good unit testing framework/tool for complicated project that have AJAX
Can anybody help me understand why are there two loops here? <?php // create
Can anybody help me to create function that will accept for parameter xml string
Can anybody help, I`m starter in web? Here is code: <head> <meta http-equiv=Content-Type content=text/html;
Can anybody help me how can I invoke a JSP page from a Servlet
can anybody help me understand how Honda achieved this effect: http://testdays.hondamoto.ch/ I mean the
Can anybody help how to setup a automatic backup of mysql database and then
can anybody help me how to nice integrate doctrine 2.0 into ZF 1.10? 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.