Here is some of the code, the script parses through multiple xml files and adds the fields into a database. [code] <?php function better_odbc_num_rows($con,$sql) { $result = odbc_exec($con,$sql); $count=0; while($temp = odbc_fetch_into($result, &$counter)){ $count++; } return $count; } function start_tag($parser, $name, $attribs) { global $current; global $attributes; global $guid; $current = $name; if ($current == "TAG1") $guid = $attribs["ID"]; if ($current == "PERSON") $attributes = $attribs["TYPE"]; } function end_tag($parser, $name) { global $variables; if ($name == "TAG1") { $odbc = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "database.mdb", "", "") or die('Could Not Connect to ODBC Database!'); $query = "SELECT * FROM Table1 WHERE ID = '$guid'"; $rs = odbc_exec($odbc, $query); $count = better_odbc_num_rows($odbc, $query); if ($count != 1) { $query = "INSERT INTO QUERY"; //$temp = $guid; $rs = odbc_exec($odbc, $query); if(!$rs) { echo "<script language=\"Javascript\">alert(\"There was an error inserting into the database, please try again\")</script>"; exit(); } } else echo "Duplicate Record Skipped...'$guid'<br />"; odbc_close($odbc); } } ....... $dir = "path to folder with xml files"; // open directory and parse file list if (is_dir($dir)) { if ($dh = opendir($dir)) { // iterate over file list // print filenames while (($filename = readdir($dh)) !== false) { if (! ($xmlparser = xml_parser_create()) ) { die ("Cannot create parser"); } xml_set_element_handler($xmlparser, "start_tag", "end_tag"); xml_set_character_data_handler($xmlparser, "tag_contents"); //echo $dir."/".$filename; if (($filename != ".") && ($filename != "..") && (substr($filename,strlen($filename-3),strlen($filename)) != "doc")) { if (!($fp = fopen($dir."/".$filename, "r"))) { die("cannot open ".$filename); } while ($data = fread($fp, 4096)) { $data=eregi_replace(">"."[[:space:]]+"."<","><",$data); if (!xml_parse($xmlparser, $data, feof($fp))) { $reason = xml_error_string(xml_get_error_code($xmlparser)); $reason .= " ".xml_get_current_line_number($xmlparser); die($reason); } } fclose($fp); } if (!(file_exists("path to processed xml files".substr($filename,0,15).".xml")) || !(file_exists("path to processed word docs".substr($filename,0,15).".doc"))) { if (($filename != ".") && ($filename !="..")) { if (substr($filename,strlen($filename-3),strlen($filename)) == "xml") { rename($dir."/".$filename, "path to processed xml".substr($filename,0,15).".xml") or die("Could not move .xml file"); $filecount++; } if (substr($filename,strlen($filename-3),strlen($filename)) == "doc") { rename($dir."/".$filename, "path to processed word docs".substr($filename,0,15).".doc") or die("Could not move .doc file"); } } } else if (($filename != ".") && ($filename !="..")) { unlink($dir."/".$filename); } xml_parser_free($xmlparser); } // close directory closedir($dh); } [/code] I can include more if needed. The function tag_contents Due to the sensitive nature of the material I've had to strip out alot of info such as variable names and queries, but the script did work when I used it on a small number of xml files. It didn't break until I attempted to use it on a much larger number of xml files. [!--quoteo(post=349153:date=Feb 24 2006, 04:14 PM:name=Caesar)--][div class=\'quotetop\']QUOTE(Caesar @ Feb 24 2006, 04:14 PM) [snapback]349153[/snapback][/div][div class=\'quotemain\'][!--quotec--] Please provide some example code that we can look through. [/quote]