Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML::SIMPLE - XMLin() error

Status
Not open for further replies.

cb49747

MIS
Apr 23, 2002
181
US
I have a program used to read a xml file and then update a mysql database with info from the xml file. Below is some of the program.

Code:
   use XML::Simple;
   use Data::Dumper;

# create object
$xml = new XML::Simple;

# read XML file
$data = $xml->XMLin($xml_file);

# access <post> array

$update_count = 0;
 $dbh = DBI->connect( "dbi:mysql:$db", "$user", "$password" )                  
             or die "Can't connect to $db: $DBI::errstr\n";
foreach $e (@{$data->{post}}) { 

   $username = $e->{username}; $pagetext = $e->{pagetext}; $dateline = $e->{dateline};
   
   $update_posts = $dbh->prepare( "UPDATE vb_post SET username = '$username' WHERE dateline = $dateline" );
   $update_posts->execute();
   
   $update_count++;

}

$dbh->disconnect;

If the xml file is small say less than 100k it works fine if the xml file is larger than 100k I get the below error message.

Code:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@stargateforum.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
 
oops, didn't finish my post.

I assume the error has to be comming durring the

$data = $xml->XMLin($xml_file);

line, but am not sure how to correct this or to even find what exactly is causing this.

Any help would be greatly appreciated.
 
cb49747 said:
... if the xml file is larger than 100k I get the below error message.
How large is the file you're trying to parse? XML::Simple isn't made for large XML files - depending on the data, it might be easier to use XML::parser.
 
Well when it works the files seem to be less than 100k and when it doesn't work they seem to be larger than 100k. For example one file that does work is 346k and has about 1200 records in it with each record containing 6 fields.

I was think it had something to do with the file size.

I will try the xml::parser

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top