I have the below HTML text stored in a variable $domText
<TR class="tableclass">
<TD>Veteran Job Information</TD>
<TD>9.00</TD>
<TD>1.2</TD>
<TD><INPUT type = "text" name = "notes"></TD>
</TR>
I want to check if the Text content in the First (Here "Veteran Job...") is equal to "Benefit Job" then need to store the values in second and third (Here 9.00 and 1.2) tags to a PHP Variable.
Below is what I have tried to do, But I am getting errors and my code is not working at all. "Invalid argument supplied for foreach()"
$dom_ChangeResults = new DOMDocument();
$dom_ChangeResults->loadHTML($domText); //Load the current changes as HTML String
$dom_TableTags = $dom_ChangeResults->getElementsByTagName("TR"); //Check table data tags for Full time to PartTime Change
$rows = $dom_TableTags->item(0)->getElementsByTagName('TD');
/*** 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 />';
}