I would say yes to both. The XML :: Simple library will create the entire tree in memory, and this will be a large multiple file size. For many applications, if your XML is more than 100 MB or so, it is almost impossible to fully load into memory in perl. The SAX parser is a way to get "events" or notifications when reading a file, and tags open or close.
Depending on your usage patterns, either the SAX parser or the DOM may be faster: for example, if you are trying to process only a few nodes or each node in a large file, SAX mode is probably best. For example, reading a large RSS feed and trying to parse every element in it.
On the other hand, if you need to cross-reference one part of a file to another part, a DOM parser or access through XPath will make more sense - writing it with the inside out method that the SAX parser requires will be awkward and complicated.
I recommend using the SAX parser at least once, because it requires reasonable thinking, this is a good exercise.
I have had good success with XML :: SAX :: Machines for setting up SAX analysis in perl - if you want to easily configure multiple filters and pipelines. For simpler settings (for example, in 99% of cases) you only need one sax filter (look at XML :: Filter :: Base) and tell XML :: SAX :: Machines to simply parse the file (or read from the file descriptor) using your filter. Here is a detailed article.
source share