Prevent tidy from adding html tags
Try the show-body-only option.
e.g.
$s = '<form method="post" action="?"><table><tr><td><input tpye="submit"></table>';echo tidy_parse_string($s, array('show-body-only'=>true, 'indent'=>true));
prints
<form method="post" action="?"> <table> <tr> <td> <input tpye="submit"> </td> </tr> </table></form>
(string has been repaired and indented but no html/body wrapper added).Can be combined with the output-xhtml option which in this case would also add the slash for the empty input element.