tags:

views:

125

answers:

2

Dear SO Readers,

Currently I am working with XML and I want to know what would be best approach to validate XML against XML Schema, parse it and store it back to MySQL database using Perl ?

I think of XML::Xerces for parsing purpose but not sure if it's the right approach.

Note: I have very large XML file >1GB size.

+3  A: 

XML Xerces will match your needs. I am using it and i really like it.

In addition to your first edit:

Since your XMl File is very big you have to think of optimizing your parsing process since lot of memory and time can be used for that.

Found an nice small example to get started:

XML Validation with Perl

Another Add:

If you dont want to write simple XML to your Database...it is important that you have an eye on your data, since your validation is outdated after you've written it to the Database in a different form. Be sure that you validate with a good scheme and some extra validators. Large XML can be tricky sometimes.

bastianneu
Prepare to answer the next question in this unforgettable series: "How do I parse XML using XML::Xerces?"
innaM
you know each other Manni and Rachel? :-)
bastianneu
A: 

You could use a XSD to validate the XML and if you can format the XML into something MySQL can just import/insert. Here is an example

Phill Pafford