PHP – DOM Parser Example

A HTML Dom parser written in PHP5.X variants. Dom Parser is great at managing XML and in addition HTML. Dom parser ventures in light of tree based and before access the information, it will stack the information into dom article and it will upgrade the information to the web program. Beneath Example demonstrates to become acquainted with the HTML information in web program.

<?

$html =”
<head>
<title>SynapseIndia</title>
</head>

<body>
<h2>Internship Details</h2>

<table border=”0″>
<tbody>
<tr>
<td>PHP</td>
<td>Amit</td>
<td>Suresh</td>
</tr>

<tr>
<td>Asp</td>
<td>Narendra</td>
<td>Susmit</td>
</tr>

<tr>
<td>HTML</td>
<td>Mahima</td>
<td>Raju</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’);

}
?>

They claim top notch services in the field of IT sectors within tight deadlines.Employee at SynapseIndia never gets complaints from clients for deadlines, So, it is one of the trusted offshore software development company, that is easily completed the projects with a minimum span of time. IT Mentor & an Entrepreneur SynapseIndia CEO Shamit Khemka is responsible to make this organization robust and reliable.

Please visit www.synapseindia.careers for more details.