whitevamp
02-10-2010, 11:38 PM
I have a php parser script that is working ok for single file parsing, but id like it to parse multipul file from a directory
( dir0/file1 dir0/file2 dir0/dir1/file1 dir0/dir1/file2 etc: ) i have tryed different things but to avale.
here is the code that works for single file parsing.
<?php
include_once('simple_html_dom.php');
$html = file_get_html('1.html');
$e = $html->find('table', 0)->find('pre', 0);
$body = '';
foreach ($e as $element)
$body .= '' . $element->plaintext . '';
$body .= '';
$html = str_get_html($body);
$html->save('result.htm');
?>
here is a pice of code that i have tryed.
<?php
include_once('simple_html_dom.php');
$strDir = ('D:\simplehtmldom\test');
$html = file_get_html ($strFile);
$objHandle = opendir($strDir);
while(($strFile = readdir($objHandle)))
{
if($strFile != ".." && $strFile != ".")
{
$e = $html->find('table', 0)->find('pre', 0);
$body = '';
foreach ($e as $element)
$body .= '' . $element->plaintext . '';
$body .= '';
$html = str_get_html($body);
$html->save('$strDir.$strFile.txt');
}
}
closedir($objHandle);
?>
and thx inadvance for any help on this.
( dir0/file1 dir0/file2 dir0/dir1/file1 dir0/dir1/file2 etc: ) i have tryed different things but to avale.
here is the code that works for single file parsing.
<?php
include_once('simple_html_dom.php');
$html = file_get_html('1.html');
$e = $html->find('table', 0)->find('pre', 0);
$body = '';
foreach ($e as $element)
$body .= '' . $element->plaintext . '';
$body .= '';
$html = str_get_html($body);
$html->save('result.htm');
?>
here is a pice of code that i have tryed.
<?php
include_once('simple_html_dom.php');
$strDir = ('D:\simplehtmldom\test');
$html = file_get_html ($strFile);
$objHandle = opendir($strDir);
while(($strFile = readdir($objHandle)))
{
if($strFile != ".." && $strFile != ".")
{
$e = $html->find('table', 0)->find('pre', 0);
$body = '';
foreach ($e as $element)
$body .= '' . $element->plaintext . '';
$body .= '';
$html = str_get_html($body);
$html->save('$strDir.$strFile.txt');
}
}
closedir($objHandle);
?>
and thx inadvance for any help on this.