If you parse files of this size, you need to avoid any parser that tries to load the entire document in memory and build a domain object model (DOM).
Instead, find a SAX style parser β one that treats the input file as a stream, raising events when events and attributes are encountered. This approach allows you to process the file gradually, without having to store the whole thing in memory at once.
Bevan source share