How to modify a huge XML file by StAX?
问题 I have a huge XML (~2GB) and I need to add new Elements and modify the old ones. For example, I have: <books> <book>....</book> ... <book>....</book> </books> And want to get: <books> <book> <index></index> .... </book> ... <book> <index></index> .... </book> </books> I used the following code: XMLInputFactory inFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inFactory.createXMLEventReader(new FileInputStream(file)); XMLOutputFactory factory = XMLOutputFactory