Should I use Perl or PHP for parsing a large XML file?
I want 开发者_开发问答to parse a large XML file and I have two options: Perl or PHP. Being new to both languages what would be your suggestion about language of choice for parsing a large XML file?
And what modules are more appropriate for the task at hand?
Use the language that you are most comfortable with.
If you decide to use Perl, please refer back to the "parsing XML using Perl"-questions you asked recently:
- What is the best tool for parsing XML and storing data in a database?
- How to read data from an XML file and store it into database(MySQL) ?
- What is the best way to validate XML against XML Schema, parsing it and storing data back to MySQL Database using Perl ?
- What would be your choice of XML Parsers in Perl for parsing > 15 GB Files ?
XML is usually parsed in one of two modes: stream or DOM. DOM is convenient, but unsuitable for large files. XML::Twig from CPAN has mixed mode, which has advantages of both modes.
PHP has a built in function called simplexml which makes it very easy to handle XML files.
Just off the cuff - I have no knowledge of the specific XML parsing capabilities of either language - I would say if it's parsing, go Perl. Perl's regular expression support is excellent and makes it the language of choice when there is parsing to be done. Your mileage may vary.
精彩评论