I was playing with the new features of PHP5 (the Tidy support and the DOM support).
I wrote the following code:
Code: Select all
<?php
$dom = new domdocument;
$dom->load("test2.html");
$dom->formatOutput = TRUE;
$params = $dom->getElementsByTagName('table');
foreach ($params as $param) {
if ($param -> getAttribute('border')) {
$param -> setAttribute('border', 0);
}
}
$dom->saveHTMLFile('test.html');
$options = array("output-xhtml" => true, "clean" => true, "indent" => true, "indent-spaces" => 4, "wrap" => 100);
$tidy = tidy_parse_file("test.html", $options);
tidy_clean_repair($tidy);
$fp = fopen('test.html', 'w');
fwrite($fp, $tidy);
fclose($fp);
?>Does anyone have a better solution? or ideas?
p3x