Reputation: 1666
Using Perl how to export Mysql table into xml file the same format as mysqldump do with command like this:
mysqldump --xml -u root -proot dbname tablename >tablename.xml
I know some Perl modules like XML::TreePP easy to use but their problem when they load xml file they have to load the entire file into memory before parsing and if the file size is larger than the allowed process memory will crash.
Upvotes: 0
Views: 1247
Reputation: 2662
If you need to parse very large XML documents, there's a particular category of XML parsers, SAX(Simple API for XML) that functions as a stream parser and emits events while parsing the XML document. On CPAN you can find XML::LibXML::SAX (part of the XML::LibXML module on CPAN) which implements SAX and can be used to parse large XML documents :
Such an interface is useful if very large XML documents have to be
processed and no DOM functions are required. By using this interface
it is possible to read data stored within an XML document directly
into the application data structures without loading the document
into memory.
You can read another SO thread about a similar problem where XML::Twig was recommended.
Upvotes: 1