tags:

views:

305

answers:

4

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?

+1  A: 

PHP has a built in function called simplexml which makes it very easy to handle XML files.

Patrick
He says "large" and simple XML loads the whole stucture in memory...
danieltalsky
Good thing nobody listened to Bill Gates about ram huh?
Patrick
Patrick, ever loaded 1Gig file into DOM in an interpreted language? I did. NOT pretty.
DVK
A: 

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.

Daniel Bingham
Regular expressions have little to do with parsing non-regular languages.
Svante
Are you suggesting to parse XML with regular expressions?
innaM
And now Alcon has 2 problems...
DVK
+4  A: 

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.

Alexandr Ciornii
+7  A: 

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:

innaM
This is the only correct answer. Both languages have highly-developed XML parsing utilities, so which is "best" depends on other factors.
Ether