Code:
<head>
</head>
<body>
  <td>
    <tr>
    </tr>
  </td>
</body>
Use a stack.
Opening tag pushed onto the stack
Closing tag pops the stack and compares (they should be the same).